Judgment Labs Logo
Other

Celery

Trace Celery worker spans with Judgment.

Celery tracing uses the standard OpenTelemetry Celery instrumentation and routes worker spans through Judgment.

Initialize tracing inside the worker process.

uv add judgeval celery opentelemetry-instrumentation-celery
pip install judgeval celery opentelemetry-instrumentation-celery
celery_tracing.py
from celery import Celery
from celery.signals import worker_process_init
from judgeval import Tracer
from opentelemetry.instrumentation.celery import CeleryInstrumentor

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


@worker_process_init.connect(weak=False)
def init_celery_tracing(*args, **kwargs):
    Tracer.init(project_name="celery_app")
    Tracer.registerOTELInstrumentation(CeleryInstrumentor())


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

On this page

No Headings