uber-common / opentracing-python-instrumentation

A collection of Python instrumentation tools for the OpenTracing API
MIT License
164 stars 58 forks source link

traced_function complains about wrong scopemanager when using no-op tracer #80

Closed nicholasamorim closed 5 years ago

nicholasamorim commented 5 years ago

I have a Tornado application and as expected, I initialize the jaeger-client passing opentracing.scope_managers.tornado.TornadoScopeManager as scope_manager.

If tracing is off, our app simply uses the no-op tracer in opentracing.tracer.

That's when the problems start. If we're using the no-op tracer, traced_function fails.

RuntimeError: scope_manager is not TornadoScopeManager

Is this intentional or is this a bug?

The same problem happens when calling request_context.span_in_stack_context while using the no-op tracer.

yurishkuro commented 5 years ago

We may need to relax the condition and return a dummy context.

https://github.com/uber-common/opentracing-python-instrumentation/blob/06ec7bbfa37967876343ca32ecb2fe4bda42ae05/opentracing_instrumentation/request_context.py#L211-L212

cc @carlosalberto any thoughts?

nicholasamorim commented 5 years ago

Can we just check if the opentracing.tracer is the no-op one and return a dummy context?

Is there already a Dummy context in the code?