OpenTelemetry Celery Integration

Instrument celery to report Celery APP operations.

There are two options for instrumenting code. The first option is to use the opentelemetry-auto-instrumentation executable which will automatically instrument your Celery APP. The second is to programmatically enable instrumentation as explained in the following section.

Usage

Be sure rabbitmq is running:

docker run -p 5672:5672 rabbitmq
from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider

trace.set_tracer_provider(TracerProvider())
# TODO: configure span exporters

from opentelemetry.ext.celery import CeleryInstrumentor
CeleryInstrumentor().instrument()

from celery import Celery

app = Celery("tasks", broker="amqp://localhost")

@app.task
def add(x, y):
    return x + y

add.delay(42, 50)

API

class opentelemetry.ext.celery.CeleryInstrumentor[source]

Bases: opentelemetry.auto_instrumentation.instrumentor.BaseInstrumentor