How to get TraceId and SpanID from OTEL Tracing

331 views Asked by At

I am using SpringBoot and Graphql for a module as well using OTEL. I need spanID and traceID in the logs of the application.

  • trace_id: OTel trace trace id, must be present in every log record produced in request context.
  • span_id: OTel trace span id, must be present in every log record produced in request context

In the Query of Subgraph, I tried to write

System.out.println(Span.current().getSpanContext().getTraceId());

But getting for every request:

00000000000000000000000000000000

Can anyone tell me what is an appropriate way to generate traceID and SpanID?

1

There are 1 answers

1
Danish Khan On

You need to enable the otel javaagent, since it looks like it's disabled.