Code Monkey home page Code Monkey logo

python-redis's Introduction

Build Status

Redis Opentracing

This package enables distributed tracing for the Python redis library.

Note: If you need to use the old OpenTracing 1.0 API, use the 0.x releases.

Installation

Run the following command:

$ pip install redis_opentracing

Getting started

Tracing a Redis client requires calling init_tracing() and optionally specify an OpenTracing-compatible tracer. See the examples directory for several different approaches.

import redis
import redis_opentracing

# If not provided, opentracing.tracer will be used.
redis_opentracing.init_tracing(tracer)

client = redis.StrictRedis()
client.set('last_access', datetime.datetime.now())

It's possible to trace only specific Redis clients:

redis_opentracing.init_tracing(tracer, trace_all_classes=False)
redis_opentracing.trace_client(client)

# Only commands and pipelines executed through this client will
# be traced.
res = client.get('last_access')

It's also possible to trace only specific pipelines:

redis_opentracing.init_tracing(tracer, trace_all_classes=False)

pipe = client.pipeline()
redis_opentracing.trace_pipeline(pipe)

# This pipeline will be executed as a single MULTI command.
pipe.lpush('fruits', 'lemon', 'watermelon')
pipe.rpush('fruits', 'pineapple', 'apple')
pipe.execute()

When pipeline commands are executed as a transaction, these commands will be grouped under a single MULTI operation. They'll also appear as a single operation in the trace. Outside of a transaction, each command will generate a span.

And it's also possible to trace only specific pubsub objects:

redis_opentracing.init_tracing(tracer, trace_all_classes=False)

pubsub = client.pubsub()
redis_opentracing.trace_pubsub(pubsub)

pubsub.subscribe('incoming-fruits')
msg = pubsub.get_message() # This message will appear as a 'SUB' operation.

Incoming messages through get_message(), listen() and run_in_thread() will be traced, and any command executed through the pubsub's execute_command() method will be traced too.

Further information

If you’re interested in learning more about the OpenTracing standard, please visit opentracing.io or join the mailing list. If you would like to implement OpenTracing in your project and need help, feel free to send us a note at [email protected].

License

Apache 2.0 License

python-redis's People

Contributors

berkowitzi avatar carlosalberto avatar moijes12 avatar pikbot avatar ror6ax avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-redis's Issues

add Travis

Adding CI to run the tests would be great.

Is there a way to inject a parent span context?

The current call redis_opentracing.init_tracing(cart_tracer, trace_all_classes=False)
initialized the tracer, but there is no child of component here or else where. Can you help me understand how to pass in the parent context to redis_opentracing so the call to redis is a subspan?

pip installation is broken

Collecting redis_opentracing
  Using cached https://files.pythonhosted.org/packages/e2/69/7519ff18c7444a96f5580e1594597ba53b8798e26b37aba5199970dff1c6/redis_opentracing-0.1.0.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-YpIjpG/redis-opentracing/setup.py", line 3, in <module>
        version = open('VERSION').read()
    IOError: [Errno 2] No such file or directory: 'VERSION'

Packaged file does not have VERSION file inside of it, hence the installation failure. Please re-release the artifact.

No LICENSE file

The setup.py file states that the code is under the BSD license, but there is no corresponding LICENSE file. Having a corresponding LICENSE file would make it a lot clearer.

My redis traces are not being connected to my span

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.