Send traces with OpenLLMetry
Send traces from applications instrumented with OpenLLMetry by Traceloop.
This guide sends traces from an application instrumented with OpenLLMetry. Tracing reads the model, tokens and messages of LLM calls, from current releases, which write GenAI semantic conventions, and from older ones, which write gen_ai.prompt.0.content and similar.
Before you start
You need an API key with the traces:write scope. Create one under Settings in the dashboard, or run div login.
Send traces with the Traceloop SDK
-
Install the SDK.
pip install traceloop-sdk -
Point it at tracing, and turn off its metrics and logs. Tracing receives traces only, and refuses metrics and logs with
404.export TRACELOOP_BASE_URL=https://api.divergentlabs.xyz/api/otlp export TRACELOOP_HEADERS="Authorization=Bearer%20$DIVERGENT_API_KEY" export TRACELOOP_METRICS_ENABLED=false export TRACELOOP_LOGGING_ENABLED=false%20is the space afterBearer. With a literal space, the export is refused with401. -
Initialize it at startup.
from traceloop.sdk import Traceloop Traceloop.init(app_name="my-app")
Send traces with an instrumentation alone
To use one OpenLLMetry instrumentation with your own tracer provider, install it with the OpenTelemetry SDK and exporter, set OTEL_EXPORTER_OTLP_ENDPOINT and OTEL_EXPORTER_OTLP_HEADERS as in Send traces from Python, and instrument the library:
from opentelemetry.instrumentation.openai import OpenAIInstrumentor
OpenAIInstrumentor().instrument()
Keep content out of traces
Set TRACELOOP_TRACE_CONTENT=false.