-
Notifications
You must be signed in to change notification settings - Fork 182
Scope Manager: Should it return Noop-types for Scope.active / Tracer.activeSpan? #116
Comments
I think it was a bug in Java NoopTracer, which has been fixed. The Scope Manager concept is somewhat orthogonal to the Tracer (esp. #114), it should be possible to use a real thread-local based scope manager with a Noop tracer. |
Yes and no. It probably was a bug that |
@cwe1ss I think there should be two ways of using NoopTracer, (a) with a normal ScopeManager (thread-local), and (b) with a lightweight NoopScopeManager. opentracing/opentracing-java#263 implements the option (b), and only that option. I think is should also allow option (a). Specifically, this line is incorrect, it should delegate to |
There was also this PR opentracing/opentracing-java#167 related to this topic. Switch from "real" tracer to noop shouldn't fail on NPE. |
I think this is more of sugar on top of the API, so I think this is not important to include in the specification itself. |
IHMO, the issue/PR @pavolloffay would be a nice thing to have, and would also address the point @yurishkuro made. Regarding the specification: I think we need to change/update it to reflect this (and add any clarification as needed). Good thing we are still in the draft stage of it ;) |
// about opentracing-ruby Returning NOOP_INSTANCE may get especially confusing with https://github.com/opentracing/specification/blob/master/rfc/trace_identifiers.md#specification-changes . E.g. a logging library may include something like if tracer.active_span
log_metadata[:trace_id] = tracer.active_span.context.trace_id
end which doesn't really make sense if you have tracing disabled / working with noop instance. I'd rather not add a dummy trace_id to the logs if I'm dealing with a noop instance. |
Java has recently merged opentracing/opentracing-java#263 (and the same change is pending in C# (opentracing/opentracing-csharp#84)) which changes the behavior of the
NoopTracer
: It will now always returnNoopScope.INSTANCE
andNoopSpanImpl.INSTANCE
instead ofnull
values.However, if people rely on these methods to never return
null
then this will violate the current "Scope Manager" RFC (see quote below) and it will ultimately lead to null pointer exceptions when people switch from a NoopTracer to a real tracer.Did I misinterpret this risk? If not, should we revert this change in Java or should we change the RFC to state that ALL scope managers should return Noop-types for
Scope.active
andTracer.activeSpan
?/cc @carlosalberto (author of the RFC)
/cc @natehart @yurishkuro (people who contributed to the Java PR)
/cc @MikeGoldsmith (people wo contributed to the C# PR)
PS: @carlosalberto the RFC currently doesn't mention the convenience accessor
Tracer.activeSpan
- should it be added to the RFC?The text was updated successfully, but these errors were encountered: