opentracing-contrib / python-tornado

OpenTracing instrumentation for Tornado
Apache License 2.0
9 stars 12 forks source link

python-tornado tracing compatibility with jaegertracing/all-in-one docker image #6

Open castrapel opened 6 years ago

castrapel commented 6 years ago

Hi, I'm having trouble with getting Tornado tracing working in conjunction with the jaegertracing docker image. I'm running my app on Python 3.5

Without any additional configuration, should this work when both services run locally?

Here's my app initializer: ` def make_app(): """make_app.""" .... tracer = opentracing.Tracer(scope_manager=TornadoScopeManager())

tornado_opentracing.init_tracing()

app = tornado.web.Application([
    (r"/", IndexHandler),
    ...............
],
    opentracing_tracing=tornado_opentracing.TornadoTracing(tracer),
    opentracing_trace_all=True,
    opentracing_traced_attributes=['protocol', 'uri', 'method']
)

`

Here's how I start the jaegertracing docker image:

docker run -d -p5775:5775/udp -p6831:6831/udp -p6832:6832/udp -p5778:5778 -p16686:16686 -p14268:14268 jaegertracing/all-in-one:latest

carlosalberto commented 6 years ago

Hey @castrapel

So you need to change this line:

tracer = opentracing.Tracer(scope_manager=TornadoScopeManager())

to actually create a JaegerTracer, as opentracing.Tracer is both an interface-alike class and a noop-implementation.

You will also likely need to configure the ports when calling JaegerTracer() ;) Let me know if you need further assistance :)

castrapel commented 6 years ago

Thanks for your reply Carlos.

When I pip install jaeger-client, opentracing 2.0.0 is downgraded to opentracing 1.3.0 ( because of this ), and opentracing 1.3.0 does not have TornadoScopeManager.

So I tried pinning to opentracing 2.0.0, and I try to create a Jaeger tracer with the code below, it doesn't like the scope_manager kwarg. How do I pass in a scope manager to the Jaeger tracer?

from jaeger_client import Config

from opentracing.scope_managers.tornado import TornadoScopeManager

...
config = Config(
        config={
            'sampler': {
                'type': 'const',
                'param': 1,
            },
            'logging': True,
        },
        service_name='consoleme',
        validate=True,
    )

tracer = config.initialize_tracer(scope_manager=TornadoScopeManager())

Result: "TypeError: initialize_tracer() got an unexpected keyword argument 'scope_manager'"

(btw your post here was extremely helpful for me to understand scope managers: https://medium.com/opentracing/announcing-python-opentracing-2-0-0-release-f4ee33de25ce )

castrapel commented 6 years ago

Hi @carlosalberto , not sure if you saw that last message so I just wanted to send a new notification. Thanks!

carlosalberto commented 6 years ago

Hey @castrapel

So it looks Jaeger does not have a OT 2.0 compliant release yet - you may want to poke them here https://github.com/jaegertracing/jaeger-client-python about that ;)

castrapel commented 6 years ago

Correct, I see an issue there already and it looks like progress is being made. In the meantime, though, should python-tornado unpin opentracing from version 2.0? https://github.com/opentracing-contrib/python-tornado/blob/master/setup.py#L18

carlosalberto commented 6 years ago

Unpinning it would mean breaking the current code - but we have a previous release, 0.1.0 that uses the 1.x family (albeit without a few cleanups and fixes).

At the same time, I'd imagine Jaeger moving relatively soon to the 2.0 API.

If you need any clean up that is not in 0.1.0 we could try to back port some changes and do a 0.1.x release ;)

carlosalberto commented 6 years ago

The package info (plus related documentation) lives here, btw: https://pypi.org/project/tornado_opentracing/0.1.0/

An alternative is to use the Jaeger instrumentation itself provides: https://github.com/uber-common/opentracing-python-instrumentation/

Hope that helps!