Collector and troubleshooting
Send to several backends through one OpenTelemetry Collector, see what the app sends on your machine, and fix spans that do not arrive.
To send the same traces to two backends (an LLM tool for the team that tunes prompts, and your APM for the on-call engineer), do not add a second exporter to the chat handler: each one adds a request at the end of every turn, and its keys live in your app. Point the app at one OpenTelemetry Collector instead, and let the Collector fan out. The keys then live in the Collector, and you can drop or rewrite attributes before anything leaves your network.
Example
The app sends to the Collector:
# The app sends to your Collector; the Collector holds the keys.
OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4318
OTEL_SERVICE_NAME=field-store
The Collector receives OTLP and sends every trace to Langfuse and to LangSmith:
# One target for the app, two backends behind it. Keys live here,
# not in the app. Exporter names: otlp_http since Collector v0.144
# (otlphttp before).
receivers:
otlp:
protocols:
http: { endpoint: 0.0.0.0:4318 }
grpc: { endpoint: 0.0.0.0:4317 }
processors:
memory_limiter:
check_interval: 1s
limit_percentage: 80
spike_limit_percentage: 20
# Optional: drop prompts and answers before they leave your network.
attributes/no-content:
actions:
- { key: gen_ai.input.messages, action: delete }
- { key: gen_ai.output.messages, action: delete }
batch: {}
exporters:
otlp_http/langfuse:
endpoint: https://cloud.langfuse.com/api/public/otel
headers:
Authorization: "Basic ${env:LANGFUSE_AUTH}"
x-langfuse-ingestion-version: "4"
otlp_http/langsmith:
traces_endpoint: https://api.smith.langchain.com/otel/v1/traces
headers:
x-api-key: ${env:LANGSMITH_API_KEY}
service:
pipelines:
traces:
receivers: [otlp]
processors: [memory_limiter, attributes/no-content, batch]
exporters: [otlp_http/langfuse, otlp_http/langsmith]
This file passes otelcol validate with the Collector’s core distribution, version 0.166.0. We did not send it to the
two backends. Run it with the keys in the Collector’s environment:
# The keys go to the Collector, never to the app.
docker run --rm -p 4318:4318 -p 4317:4317 \
-e LANGFUSE_AUTH -e LANGSMITH_API_KEY \
-v "$PWD/otel-collector.yaml:/etc/otelcol/config.yaml:ro" \
otel/opentelemetry-collector:0.166.0
Try it on your machine
To see what the app sends before you pick a backend, run a Collector that only prints:
# Prints every span it receives: for trying the layer on your machine.
receivers:
otlp:
protocols:
http: { endpoint: 0.0.0.0:4318 }
grpc: { endpoint: 0.0.0.0:4317 }
exporters:
debug: { verbosity: detailed }
service:
pipelines:
traces: { receivers: [otlp], exporters: [debug] }
docker run --rm -p 4318:4318 -p 4317:4317 \
-v "$PWD/otel-collector.yaml:/etc/otelcol/config.yaml:ro" \
otel/opentelemetry-collector:0.166.0
Set OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 in the app, send one message, and the Collector prints the
trace. This is the setup this library was verified against, over http/json, http/protobuf and grpc: one trace per
turn, the page’s run span as the root, the server’s model steps and the page’s tool calls as its children.
Troubleshooting
Set WEB_AGENTS_OTEL_DEBUG=true first: the layer then prints each exported span to the console, redacted.
No span arrives, and nothing fails
With no OTEL_EXPORTER_OTLP_* variable, no exporters, no spanProcessors and no provider registered by the app,
the layer is off, and says so once in development (Where spans go). Check that
OTEL_SDK_DISABLED is not true and WEB_AGENTS_OTEL_ENABLED is not false.
One error names a package
A protocol whose package is not installed turns that target off with one error naming it:
@opentelemetry/exporter-trace-otlp-proto for http/protobuf, @opentelemetry/exporter-trace-otlp-grpc for
grpc. Without the three OpenTelemetry peers, the layer is off and says which to install.
The server's spans arrive, the page's do not
The page posts to /api/telemetry. A relay that answers 404 makes the page stop sending: mount
the relay there. A 403 means a cross-site request or one with no Origin.
403 from the backend
For Datadog, the intake host does not match your site. For IBM Instana, the host is usually for another region than your tenant’s.
404 from PostHog
PostHog’s path does not end in /v1/traces: set the exact URL with OTEL_EXPORTER_OTLP_TRACES_ENDPOINT, not the
base variable, which appends /v1/traces.
415 from Phoenix
Phoenix accepts protobuf only: install @opentelemetry/exporter-trace-otlp-proto and set
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf.
Every model step appears twice
Your app registered @ai-sdk/otel too and appIntegrations is "keep", or conventions is "both"
(appIntegrations).
Notes
Exporter names
Since Collector 0.144 the OTLP exporters are otlp_http and otlp_grpc. The older otlphttp and otlp still
work as deprecated aliases, and most vendors’ docs still show them.
endpoint or traces_endpoint
endpoint is a base (/v1/traces is appended); traces_endpoint is used as given, as
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT is in the app.
Each backend's own rules
The protocol, the headers and the attribute to group by are on each backend’s
installation page. encoding: json on an otlp_http exporter sends JSON; the
default is protobuf, which every backend here accepts.
One pipeline per backend
When backends need different processing, give each its own traces/<name> pipeline with its own processors.
Batching
The batch processor is still the documented choice. Do not combine it with exporter-side sending_queue
batching: the Collector warns about it.