Description
In its current implementation, the OT shim doesn't preserve ScopeShim
and SpanShim
objects after creating them. This results in situations such as the following:
- The instrumentation creates and activates a span using
start_active_span()
, which results in aScopeShim
object containing aSpanShim
object. - The instrumentation then obtains the currently-active span using the shim's
active_span
property. - The
ScopeShim
returned byactive_span
isn't the same object as the one returned fromstart_active_span()
.
The reason for the behavior described above is that we only keep state in the OpenTelemetry tracer. We don't really have an OpenTracing tracer or scope manager which keep track of spans. When the user queries the shim's API for the currently-active span for example, we construct a new object from the existing OpenTelemetry object. So the returned object contains the same OpenTelemetry span, but the wrapper objects themselves aren't the same OpenTracing objects as the ones returned to the user during span creation and activation.
There doesn't seem to be an easy way to address this issue. @Oberon00 has some ideas on how this can be implemented.
Relevant discussions: