Send traces to Langfuse, Phoenix or LangSmith
L2M exports OpenTelemetry traces over OTLP/HTTP. Langfuse, Arize Phoenix and LangSmith each accept OTLP/HTTP directly, so L2M can send its traces to them with no collector in between. This page gives the settings for each one. Pick the one you use; they work the same way on the L2M side.
Tracing is off until you set an endpoint. Nothing on this page is needed to run L2M.
How the settings work
Each recipe sets two variables on the L2M API:
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: the full traces URL, including the/v1/tracespath. L2M uses it as it is. It sends traces only, so OTLP metrics (if you turn them on) do not go to a backend that does not take them.OTEL_EXPORTER_OTLP_HEADERS: comma-separatedkey=valuepairs sent with every export, for the backend's key. Values are percent-decoded, so write a space as%20. L2M never shows these values: Settings → Observability → Metrics & Traces lists header names only.
L2M sends http/protobuf by default. All three backends accept it.
Where to set them:
- Docker (the quickstart): add the variables under
environment:of theapiservice in yourdocker-compose.yml, then rundocker compose up -d. A backend on your own machine ishost.docker.internalfrom inside the container, notlocalhost. - From source: put them in
.env, or in front ofpnpm dev.
Optionally, name the service with OTEL_SERVICE_NAME=l2m so the traces are easy to find.
By default, spans carry ids, timings, model names and token counts, but no prompts or answers. To see the content of model and tool calls in the backend, also set OTEL_INSTRUMENTATION_GENAI_CAPTURE_CONTENT=SPAN_ONLY. L2M removes secrets and masks detected data before export; see content capture.
Langfuse
Langfuse takes OTLP/HTTP (protobuf or JSON) at /api/public/otel. It authenticates with HTTP Basic auth: your project's public key and secret key, joined by a colon and base64-encoded.
In Langfuse, open your project's settings and create an API key pair.
Encode the pair:
bashecho -n "pk-lf-...:sk-lf-..." | base64 -w 0On macOS, leave out
-w 0.Set, for Langfuse Cloud in the EU region:
bashOTEL_EXPORTER_OTLP_TRACES_ENDPOINT=https://cloud.langfuse.com/api/public/otel/v1/traces OTEL_EXPORTER_OTLP_HEADERS=Authorization=Basic%20<base64 string>,x-langfuse-ingestion-version=4For the US region, use
https://us.cloud.langfuse.com/api/public/otel/v1/traces. For a self-hosted Langfuse (v3.22.0 or later), use your Langfuse address, for examplehttp://localhost:3000/api/public/otel/v1/traces. Langfuse asks for thex-langfuse-ingestion-version=4header so traces show up in real time.
Source: Langfuse: OpenTelemetry.
Arize Phoenix
Phoenix takes OTLP/HTTP at /v1/traces on its own port, 6006 by default (the same port as its UI, not 4318). A local Phoenix needs no key.
Start Phoenix, for example with
phoenix serveor its container.Set, for a Phoenix on the same machine:
bashOTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://localhost:6006/v1/tracesWith L2M in Docker, use
http://host.docker.internal:6006/v1/traces.For Phoenix Cloud, or a Phoenix with authentication turned on, add your Phoenix API key:
bashOTEL_EXPORTER_OTLP_TRACES_ENDPOINT=https://app.phoenix.arize.com/s/<your-space-name>/v1/traces OTEL_EXPORTER_OTLP_HEADERS=authorization=Bearer%20<your Phoenix API key>
Phoenix also listens for OTLP over gRPC on port 4317. L2M does not send gRPC, so use the HTTP port.
Sources: Phoenix: what is my Phoenix endpoint?, Phoenix: configuration, Phoenix: OTLP settings with a bearer header.
LangSmith
LangSmith takes OTLP/HTTP at your LangSmith API URL plus /otel. It authenticates with an x-api-key header.
In LangSmith, create an API key.
Set, for LangSmith in the US region:
bashOTEL_EXPORTER_OTLP_TRACES_ENDPOINT=https://api.smith.langchain.com/otel/v1/traces OTEL_EXPORTER_OTLP_HEADERS=x-api-key=<your LangSmith API key>For the EU region, use
https://eu.api.smith.langchain.com/otel/v1/traces. For a self-hosted LangSmith, usehttps://<your host>/api/v1/otel/v1/traces.Optionally, send traces to a registered agent and environment by adding both
Langsmith-Agent-Id=<agent id>andLangsmith-Agent-Environment=<local, development, staging or production>to the headers. Send both or neither: LangSmith refuses one without the other.
Source: LangSmith: trace with OpenTelemetry.
Check that traces arrive
- Restart the L2M API with the new settings. An endpoint that is not an absolute
http://orhttps://URL stops it at start-up with a message naming the variable. - Run any workflow, for example the zero-key MCP Agent Quickstart template.
- Spans are exported in batches every 5 seconds. Look for a trace named
invoke_workflow MCP Agent Quickstartin the backend, with the agent loop, the model call and the MCP calls under it. - In L2M, Settings → Observability → Metrics & Traces shows the settings in effect and the most recent spans.
A failed export never slows a run down: it is dropped and counted in l2m_otel_spans_dropped_total. If nothing arrives, check the endpoint path, that the header value has %20 for its space, and the OpenTelemetry troubleshooting section.
Related
- OpenTelemetry: every setting, the spans L2M emits and content capture
- Observability: logs and Prometheus metrics
- OpenTelemetry Collector for agents: when to put a collector in between