We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
otel_tracer_noop:with_span/5 doesn't restore context properly
require OpenTelemetry.Tracer, as: Tracer ctx = Tracer.with_span :parent_span1 do OpenTelemetry.Ctx.get_current() end |> IO.inspect(label: "parent_span1 context"); :ok OpenTelemetry.set_default_tracer({:otel_tracer_noop, []}) Tracer.with_span :parent_span2 do OpenTelemetry.Ctx.get_current() |> IO.inspect(label: "parent_span2 context") Tracer.with_span ctx, :nested_span, %{} do OpenTelemetry.Ctx.get_current() |> IO.inspect(label: "nested_span context") end OpenTelemetry.Ctx.get_current() |> IO.inspect(label: "restored parent_span2 context") end; :ok
parent_span1 context: %{ {:otel_tracer, :span_ctx} => {:span_ctx, 226093672235243343240248130524572830431, 14684213315684633963, 1, {:tracestate, []}, true, false, true, {:otel_span_ets, #Function<2.55784961/1 in :otel_tracer_server.on_end/1>}} } parent_span2 context: %{ {:otel_tracer, :span_ctx} => {:span_ctx, 0, 0, 0, {:tracestate, []}, false, false, false, :undefined} } nested_span context: %{ {:otel_tracer, :span_ctx} => {:span_ctx, 226093672235243343240248130524572830431, 14684213315684633963, 1, {:tracestate, []}, true, false, true, {:otel_span_ets, #Function<2.55784961/1 in :otel_tracer_server.on_end/1>}} } restored parent_span2 context: %{ {:otel_tracer, :span_ctx} => {:span_ctx, 226093672235243343240248130524572830431, 14684213315684633963, 1, {:tracestate, []}, true, false, true, {:otel_span_ets, #Function<2.55784961/1 in :otel_tracer_server.on_end/1>}} }
the context is properly restored after execution of otel_trace:with_span/5
otel_trace:with_span/5
with_span(Ctx, Tracer, SpanName, Opts, Fun) -> SpanCtx = start_span(Ctx, Tracer, SpanName, Opts), Ctx1 = otel_tracer:set_current_span(Ctx, SpanCtx), Token = otel_ctx:attach(Ctx1), try Fun(SpanCtx) after otel_ctx:detach(Token) end.
The text was updated successfully, but these errors were encountered:
@DenysGonchar did you try this change? I'm actually not seeing what is different from the current code in your suggestion?
Sorry, something went wrong.
No branches or pull requests
description:
otel_tracer_noop:with_span/5 doesn't restore context properly
here is a code snippet that demonstrates the problem:
and the output is:
expected behaviour:
the context is properly restored after execution of
otel_trace:with_span/5
proposed changes:
The text was updated successfully, but these errors were encountered: