-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
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 #753
Comments
@DenysGonchar did you try this change? I'm actually not seeing what is different from the current code in your suggestion? |
sorry for the delay. here is the current implementation: with_span(Ctx, Tracer, SpanName, Opts, Fun) ->
SpanCtx = start_span(Ctx, Tracer, SpanName, Opts),
Ctx1 = otel_tracer:set_current_span(Ctx, SpanCtx),
otel_ctx:attach(Ctx1),
try
Fun(SpanCtx)
after
otel_ctx:attach(Ctx)
end. note that the random external context is attached in the |
actually, otel_tracer_default does the same thing. 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
%% passing SpanCtx directly ensures that this `end_span' ends the span started
%% in this function. If spans in `Fun()' were started and not finished properly
%% they will be abandoned and it be up to the `otel_span_sweeper' to eventually remove them.
_ = otel_span_ets:end_span(SpanCtx),
otel_ctx:detach(Token)
end. and it also contains one more important thing - |
The behavior you're pointing out is the correct one. The original ctx is taken in, a span is started and ended (new context) and then the original is reattached. |
the behaviour is correct in the otel_tracer_default module, but broken in the otel_tracer_noop |
Could you send a PR? |
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: