OpenTracing support for Celery
Project description
Celery OpenTracing
This package enables tracing task execution in a Celery 3.1+ application via The OpenTracing Project. Once a production system contends with real concurrency or splits into many services, crucial (and formerly easy) tasks become difficult: user-facing latency optimization, root-cause analysis of backend errors, communication about distinct pieces of a now-distributed system, etc. Distributed tracing follows a request on its journey from inception to completion from mobile/browser all the way to the microservices.
As core services and libraries adopt OpenTracing, the application builder is no longer burdened with the task of adding basic tracing instrumentation to their own code. In this way, developers can build their applications with the tools they prefer and benefit from built-in tracing instrumentation. OpenTracing implementations exist for major distributed tracing systems and can be bound or swapped with a one-line configuration change.
If you want to learn more about the underlying Python API, visit the Python source code.
Installation
Run the following command:
$ pip install celery-opentracing
Usage
The provided celery.app.base.Celery
subclass allows the tracing of task scheduling and execution using the OpenTracing API. All that it requires is for a CeleryTracing
instance to be initialized using an instance of an OpenTracing tracer and treated as a standard Celery
application.
Initialize
CeleryTracing
takes the Tracer
instance that is supported by OpenTracing and an optional dictionary of desired tags for each created span. You can also specify whether you'd like the initial task publish events to be represented by a span whose trace context is propagated via request headers to the worker executing the task (enabled by default). To create a CeleryTracing
object, you can either pass in a tracer object directly or default to the opentracing.tracer
global tracer that's set elsewhere in your application:
from celery_opentracing import CeleryTracing
opentracing_tracer = # some OpenTracing tracer implementation
traced_app = CeleryTracing(tracer=opentracing_tracer, propagate=True, # propagation allows distributed tracing from
span_tags=dict(my_helpful='tag')) # publisher over broker to workers.
@traced_app.task(bind=True)
def my_task(self):
return True
or
from celery_opentracing import CeleryTracing
import opentracing
opentracing.tracer = # some OpenTracing tracer implementation
traced_app = CeleryTracing(propagate=False) # Tracer defaults to opentracing.tracer. No publish span creation or propagation to worker execution context will configured as well.
@traced_app.task(bind=True)
def my_task(self):
return True
Further Information
If you're interested in learning more about the OpenTracing standard, please visit opentracing.io. If you would like to implement OpenTracing in your project and need help, feel free to send us a note at community@opentracing.io.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file Celery-OpenTracing-0.0.1.tar.gz
.
File metadata
- Download URL: Celery-OpenTracing-0.0.1.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/2.7.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | de8ccbf2d53275127e64a770566bed790de2e67cf222cad0dc6c73c211c8b5c8 |
|
MD5 | b8dcbf2d169d0f67db741416cd92561f |
|
BLAKE2b-256 | 7cb38ab55641fb3b9ebbd8bf5e71b5f6bc79f43e0be1afc350657f07c426d2a1 |