As fo now https://github.com/carlosalberto/opentracing-python-instrumentation/tree/ot_scopemanager_integration points out to a basic, initial support for the OT 2.0 API (namely: Scopes integration). Think of it more of a prototype.
The changes consist mainly of:
-
Using a single, global
TornadoScopeManager
instance for doing the activation of both single-threaded andTornado
based activation (span_in_context()
andspan_in_stack_context()
). This is possible as the mentionedScopeManager
stores theScope
/Span
through aStackContext
, if any is detected, or else in a TLS field (which is similar to whatopentracing-python-instrumentation
does at the moment. -
For doing the
span_in_context()
part, a simpleScope
is returned, which exposes aspan
property, just as the originalRequestContext
does. -
For doing the
span_in_stack_context()
part, we enter atracer_stack_context()
(used to create a 'storage' for any activeSpan
at the moment), activate the passedSpan
and return such context (and any further call down the call couldScopeManager
's methods, as anyTornadoScopeManager
instances references any current context).
Notes:
-
Removed
ThreadSafeStackContext
as it's not used anymore (from here) - did not removeRequestContext
norRequestContextManager
as they are still used/checked by the tests. Could be removed afterwards, doing a clean up. -
We could probably add some stuff for better integration witht the OT 2.0 API (i.e.
get_current_span()
could take an optionalscope_manager
parameter to use any manager other than the global-default one).