@@ -373,8 +373,7 @@ TraceManager::Trace::InitTracer(
373
373
std::chrono::duration_cast<std::chrono::nanoseconds>(
374
374
std::chrono::steady_clock::now ().time_since_epoch ())
375
375
.count ();
376
- auto root_span =
377
- StartSpan (" InferRequest" , steady_timestamp_ns);
376
+ auto root_span = StartSpan (" InferRequest" , steady_timestamp_ns);
378
377
// Initializing OTel context and storing "InferRequest" span as a root span
379
378
// to keep it alive for the duration of the request.
380
379
otel_context_ = opentelemetry::context::Context ({kRootSpan , root_span});
@@ -386,6 +385,12 @@ TraceManager::Trace::StartSpan(
386
385
TRITONSERVER_InferenceTraceActivity activity, uint64_t timestamp_ns,
387
386
uint64_t trace_id)
388
387
{
388
+ uint64_t parent_id;
389
+ LOG_TRITONSERVER_ERROR (
390
+ TRITONSERVER_InferenceTraceParentId (trace, &parent_id),
391
+ " getting trace parent id" );
392
+ std::string parent_span_key = " " ;
393
+
389
394
// Currently, only 2 types of sub-spans are supported:
390
395
// request span and compute span. Compute span is a leaf span
391
396
// and can not be a parent of any sub-span. If parent_id==0,
@@ -396,16 +401,13 @@ TraceManager::Trace::StartSpan(
396
401
// If parent_id > 0, then this is a child trace, spawned from
397
402
// the ensamble's main request. For this instance, the parent
398
403
// span is the ensembles's request span.
399
- uint64_t parent_id;
400
- LOG_TRITONSERVER_ERROR (
401
- TRITONSERVER_InferenceTraceParentId (trace, &parent_id),
402
- " getting trace parent id" );
403
- std::string parent_span_key =
404
- (parent_id == 0 && activity == TRITONSERVER_TRACE_REQUEST_START)
405
- ? kRootSpan
406
- : (activity == TRITONSERVER_TRACE_REQUEST_START)
407
- ? kRequestSpan + std::to_string (parent_id)
408
- : kRequestSpan + std::to_string (trace_id);
404
+ if (parent_id == 0 && activity == TRITONSERVER_TRACE_REQUEST_START) {
405
+ parent_span_key = kRootSpan ;
406
+ } else if (activity == TRITONSERVER_TRACE_REQUEST_START) {
407
+ parent_span_key = kRequestSpan + std::to_string (parent_id);
408
+ } else if (activity == TRITONSERVER_TRACE_COMPUTE_START) {
409
+ parent_span_key = kRequestSpan + std::to_string (trace_id);
410
+ }
409
411
410
412
std::string display_name = " compute" ;
411
413
const char * model_name;
0 commit comments