opentracing-contrib / python-redis

OpenTracing instrumentation for the Redis client.
Apache License 2.0
20 stars 14 forks source link

My redis traces are not being connected to my span #10

Closed mjgorman closed 5 years ago

mjgorman commented 5 years ago

I'm doing a little sample POC of OpenTracing for our team and I am getting the traces for redis, but they're separate from my spans which are running those redis commands. I'm setting a tag and that all works, but in jaeger they just come out as separate traces making it sort of useless.

screen shot 2018-12-07 at 3 14 30 pm

screen shot 2018-12-07 at 3 10 23 pm
carlosalberto commented 5 years ago

Hey @mjgorman

If I understand correctly, you want the INCR and GET to automatically become children of your redis-span Span, correct? If that's the case, this is part of an ongoing effort, as part of adopting the OT 2.0 API (which adds active Span propagation & handling): https://github.com/opentracing-contrib/python-redis/tree/v1.0.0

The ETA for this effort to be finished is 1-2 weeks ;)

mjgorman commented 5 years ago

@carlosalberto great to hear. Glad it wasn't just something I was doing incorrectly.

carlosalberto commented 5 years ago

Hey @mjgorman

I just released the 1.0.0 version, which should fix this. Simply remember to update your code to look like this:

with tracer.start_active_span('redis-span') as scope:
    # Here your Redis commands and other related code.
    # As 'redis_span' is the active Span, all new Spans
    # under this block will become implicit children of it.

Let me know ;)

mjgorman commented 5 years ago

Switching start_span to start_active_span throw an error.

  File "02b.py", line 36, in do_redis_things
    with tracer.start_active_span('redis-span') as scope:
  File "/Users/michael.gorman/sites/opentracing/python/venv/lib/python3.7/site-packages/opentracing/tracer.py", line 126, in start_active_span
    return self._noop_scope
AttributeError:  'Tracer' object has no attribute '_noop_scope'
carlosalberto commented 5 years ago

Hey @mjgorman

Thanks for the answer. So you are using Jaeger, right? It seems they still haven't released a version that implements the OT 2.0 api (which automatically detects the parent/child relationship).

As far as I know, LightStep, DataDog and Instana clients support this already ;) (I can poke the Jaeger guys and maybe help them to have this released, too). Let me know.

mjgorman commented 5 years ago

@carlosalberto Ah I see. Thank you for the informative response. I'll take it up with them.