Skip to content

Commit fd46dfb

Browse files
committed
Changed ternary to if-else
1 parent 02da628 commit fd46dfb

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

src/tracer.cc

+14-12
Original file line numberDiff line numberDiff line change
@@ -373,8 +373,7 @@ TraceManager::Trace::InitTracer(
373373
std::chrono::duration_cast<std::chrono::nanoseconds>(
374374
std::chrono::steady_clock::now().time_since_epoch())
375375
.count();
376-
auto root_span =
377-
StartSpan("InferRequest", steady_timestamp_ns);
376+
auto root_span = StartSpan("InferRequest", steady_timestamp_ns);
378377
// Initializing OTel context and storing "InferRequest" span as a root span
379378
// to keep it alive for the duration of the request.
380379
otel_context_ = opentelemetry::context::Context({kRootSpan, root_span});
@@ -386,6 +385,12 @@ TraceManager::Trace::StartSpan(
386385
TRITONSERVER_InferenceTraceActivity activity, uint64_t timestamp_ns,
387386
uint64_t trace_id)
388387
{
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+
389394
// Currently, only 2 types of sub-spans are supported:
390395
// request span and compute span. Compute span is a leaf span
391396
// and can not be a parent of any sub-span. If parent_id==0,
@@ -396,16 +401,13 @@ TraceManager::Trace::StartSpan(
396401
// If parent_id > 0, then this is a child trace, spawned from
397402
// the ensamble's main request. For this instance, the parent
398403
// 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+
}
409411

410412
std::string display_name = "compute";
411413
const char* model_name;

0 commit comments

Comments
 (0)