1

I have a gRPC API and want to add Otel based tracing to it. Every request to this API contains trace/span ID, but I am struggling to properly emit child span.

Here is an example from iex:

require OpenTelemetry.Tracer
alias OpenTelemetry.Tracer

:otel_propagator_text_map.extract([{"traceparent", "00-00000000000000001f28325aa9c79b59-37ab46991f7a64e1-00"}])
_parent = :otel_tracer.current_span_ctx()

span_ctx = Tracer.start_span("otel-test")
Tracer.set_current_span(span_ctx)
# start doing some work
:timer.sleep(100)
# work done

Tracer.end_span(span_ctx)

Not sure what is wrong here but I don't see span emitted in the iex console. As I understand when traceparent is extracted it becomes parent span automatically, hence the need to change the span via set_current_span/1.

Can someone tell me what is wrong here?

user1453428
  • 185
  • 2
  • 8

1 Answers1

1

Ok, solved.

trace-flags in traceparent header point to no sampling hence nothing in the output.

Should be: 00-00000000000000001f28325aa9c79b59-37ab46991f7a64e1-01

Source: https://www.w3.org/TR/trace-context/#examples-of-http-traceparent-headers

user1453428
  • 185
  • 2
  • 8