Skip to main content
Agent runs, model/tool calls, prompt loading, and history operations emit OpenTelemetry spans. Install a tracer provider during process startup, and flush it after requests and workers have stopped.

Export to Langfuse

Import pkg/telemetry; load the endpoint and keys from application configuration:
The endpoint is a host (optionally with port), without an https:// prefix. The last argument controls TLS. The exporter uses Langfuse’s OTLP trace path and basic authentication from the key pair. NewProvider installs a global, batched tracer provider with parent-based always-on sampling and W3C trace-context/baggage propagation. OTEL_SERVICE_NAME sets the service name. Applications needing different sampling, resource attributes, processors, or shutdown deadlines can install their own OpenTelemetry provider instead. The convenience helper currently creates traces.txt in the working directory and returns without installing a provider if that file cannot be created. It does not write a queryable trace archive there. For read-only deployments or a controlled telemetry lifecycle, configure OpenTelemetry directly rather than relying on that helper’s filesystem side effect.

Other backends

NewProvider accepts any OpenTelemetry SDK trace.SpanExporter, including one connected to your OTLP collector. Configure authentication and TLS on that exporter. Set the provider up on both HTTP/caller and durable-worker processes; each process exports its own spans. When adding provider middleware for retry/fallback, place tracing where you want attempts measured. The agent-level middleware and provider-level middleware are separate APIs and can produce different span boundaries.

Run correlation and data handling

Run lifecycle events carry trace identity for correlation. Retain run, thread, namespace, and trace identifiers in application logs without assuming a stream ID and run ID are interchangeable. Span attributes can include prompts, messages, and tool content. Apply your data retention, redaction, and access policies at collection/export. Monitor exporter failures and flush during shutdown so buffered spans are not silently lost. The embedded UI currently has no trace-query backend or Langfuse-style trace viewer. Configuring an exporter does not add one.