Skip to main content
Telemetry comes out of the box with all components. We use opentelemetry to collect metrics and traces across the entire codebase. This allows you to troubleshoot and monitor the performance and latency for every plugin and processor used by your agents.

Tracing example using Jaeger

Simplest way to test tracing setup, is to run Jaeger locally with Docker. This makes it easy to verify that telemetry is working as expected. Because the library uses otel internally, all you need to do is to install the exporter and setup the instrumentation. Step 1 - Install open telemetry OTLP exporter
# with uv:
uv install opentelemetry-sdk opentelemetry-exporter-otlp

# or with pip:
pip install opentelemetry-sdk opentelemetry-exporter-otlp-proto-grpc
Step 2 - Setup tracing instrumentation in your code Make sure to setup the instrumentation before you start the agent/server
from opentelemetry import trace
from opentelemetry.sdk.resources import Resource
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter

resource = Resource.create(
    {
        "service.name": "agents",
    }
)
tp = TracerProvider(resource=resource)
exporter = OTLPSpanExporter(endpoint="localhost:4317", insecure=True)

tp.add_span_processor(BatchSpanProcessor(exporter))
trace.set_tracer_provider(tp)
Step 3 - Run Jaeger
docker run --rm -it \
         -e COLLECTOR_OTLP_ENABLED=true \
         -p 16686:16686 -p 4317:4317 -p 4318:4318 \
         jaegertracing/all-in-one:1.51```
After this, you can run your code and see the traces in Jaeger at http://localhost:16686.

Metrics example with Prometheus

Metrics are automatically collected for all plugins and processors, a common approach is to expose the metrics from your Python program to Prometheus. Step 1 - Install prometheus exporter
# with uv:
uv install opentelemetry-exporter-prometheus prometheus-client

# or with pip:
pip install opentelemetry-exporter-prometheus prometheus-client
Step 2 - Setup metrics instrumentation in your code Make sure to setup the instrumentation before you start the agent/server
from opentelemetry import metrics
from opentelemetry.sdk.resources import Resource
from opentelemetry.sdk.metrics import MeterProvider
from opentelemetry.exporter.prometheus import PrometheusMetricReader
from prometheus_client import start_http_server

resource = Resource.create(
    {
        "service.name": "my-service-name",
    }
)

reader = PrometheusMetricReader()
metrics.set_meter_provider(
    MeterProvider(resource=resource, metric_readers=[reader])
)

start_http_server(port=9464)
You can now see the metrics at http://localhost:9464/metrics (make sure that your Python program keeps running), after this you can setup your Prometheus server to scrape this endpoint.
I