Skip to main content

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.

Build Status

Installation

Run the following command:

$ pip install signalfx-instrumentation-redis

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 community@opentracing.io.

License

Apache 2.0 License

Metadata

Release files for signalfx-instrumentation-redis 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for signalfx-instrumentation-redis 1.0.0
File Size Uploaded
signalfx-instrumentation-redis-1.0.0.tar.gz 8.6 kB Details

Release files / signalfx-instrumentation-redis-1.0.0.tar.gz

Download URL signalfx-instrumentation-redis-1.0.0.tar.gz
Size 8.6 kB
Tags Source
SHA-256 checksum
How to use checksums
bb21ac6882557e8aff3081e860bc362aff36a809a730231902da6500dddf0c1e
BLAKE2b-256 checksum
How to use checksums
7433680b2be670338cc1287ea240310d0f09f42d7ca640f84c493b337dbb0a79
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.6.11

Release history Release notifications | RSS feed

This release

1.0.0 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page