Overview
Langfuse is an open-source LLM engineering platform: traces, token and cost analytics, prompt management, and evals. It pairs with GoModel in two complementary ways:- Gateway traces. GoModel’s OpenTelemetry exporter sends a trace for every request to Langfuse’s OTLP endpoint. Every client of the gateway is covered without touching application code, and each trace shows the model, the provider that served it, latency, status, and every retry or failover — but never prompts or completions.
- Application traces. The Langfuse SDK’s OpenAI drop-in wrapper, pointed at GoModel as its base URL. Langfuse records full prompts, completions, and token usage; GoModel supplies the routing, failover, caching, and its own audit log and cost tracking underneath.
App (Langfuse SDK) -> GoModel -> OpenAI/Anthropic/Gemini/... with traces
from both hops arriving in Langfuse.
1. Send gateway traces to Langfuse
Langfuse ingests OTLP traces at/api/public/otel, authenticated with a
project’s API key pair. Base64-encode the keys:
.env file, drop them — there they would become part of the value.
Keep the default
http/protobuf protocol: Langfuse’s OTLP endpoint does not
speak gRPC. The API keys come from Project Settings -> API Keys in
Langfuse; self-hosted deployments can also pre-provision them with the
LANGFUSE_INIT_* variables.
To run Langfuse itself, see its
docker compose quickstart —
git clone https://github.com/langfuse/langfuse.git && cd langfuse && docker compose up,
UI on port 3000.
What appears in Langfuse
Each gateway request becomes one trace: aPOST /v1/chat/completions span
with a nested generation per provider call, named after the operation and
model (chat gpt-5-mini). The generation’s metadata carries
gen_ai.request.model, gen_ai.provider.name, and gomodel.provider.name
(the exact provider from your configuration), so a request that
failed over shows one generation per attempt — which
provider failed, with what error class, and which one answered. Langfuse
matches the model name against its model catalog, so gateway generations
group under the right model in its dashboards.
Two things are absent by design. Prompts and completions never leave the
gateway in telemetry — they stay in GoModel’s audit log;
Langfuse traces from the gateway carry timing and routing metadata only. And
token usage is not attached either, so cost analytics in Langfuse stay empty
on this path — GoModel’s own cost tracking has
per-request cost, or use the SDK path below to get both into Langfuse.
Streaming requests keep their HTTP server span but get no separate generation
span; OpenTelemetry
explains why.
2. Capture prompts with the Langfuse SDK
For full prompt-level traces, instrument the application with Langfuse’s OpenAI wrapper and point it at GoModel — two changed lines in an existing OpenAI-SDK app:openai/gpt-5-mini, gemini/gemini-2.5-flash,
virtual models), and every call still gets
GoModel’s failover, caching, budgets, and audit trail. The
JS/TS wrapper
works the same way.
3. One trace end to end
With both paths enabled, an LLM call produces two separate Langfuse traces — the SDK’s and the gateway’s. Propagate W3C trace context to merge them: send atraceparent header with the request and GoModel parents its spans under
the caller’s trace.
Verified with Langfuse v4.27.0 (self-hosted via docker compose) and
Langfuse Python SDK 4.15.1: gateway OTLP traces for buffered and streaming
chat across OpenAI, Anthropic, and Gemini, failover spans, SDK prompt
capture through GoModel, and trace-context propagation merging both.
Troubleshooting
Notes
- High-traffic gateways can sample gateway traces
(
OTEL_TRACES_SAMPLER=parentbased_traceidratio,OTEL_TRACES_SAMPLER_ARG=0.1) — withparentbased_*, requests whose caller sampled their trace keep their gateway spans, so propagated traces stay complete. - The full exporter reference — YAML config, per-signal endpoints, samplers, reload behavior — is in the OpenTelemetry guide. Everything there applies; Langfuse is just the OTLP backend.
- For dashboards over request-rate and latency metrics, pair this with Prometheus metrics — Langfuse holds the traces, Prometheus the metrics.