ai newsMi., 25. Nov.
EilmeldungCan Claude’s storage webhooks miss an hour-long outage?

Langfuse + OpenLLMetry: LLM observability and tracing for your LLM applications with OpenTelemetry

Langfuse and OpenLLMetry are two open source projects that answer the same question: what is really happening inside an LLM application? Which prompt was sent, which documents were retrieved, how many tokens were consumed, which step took three seconds? Without the traces a Langfuse/OpenLLMetry set

dev.toDienstag 12:30 · 24.11.4 Min. Lesezeit
Bild: dev.to

Posted on Nov 24 • Originally published at span.observer

Langfuse and OpenLLMetry are two open source projects that answer the same question: what is really happening inside an LLM application? Which prompt was sent, which documents were retrieved, how many tokens were consumed, which step took three seconds? Without the traces a Langfuse/OpenLLMetry setup provides, a RAG application or an agent remains a black box, and every odd answer becomes a blind investigation. This is what LLM observability is about, and Langfuse is one of the most used open source tools for it.

Both projects have a feature that directly interests SRE teams: they speak OpenTelemetry. OpenLLMetry is a set of instrumentations that produce OpenTelemetry spans for calls to LLMs, vector databases and frameworks. Langfuse is an LLM engineering platform (traces, prompt management, evaluations, datasets) that can receive these traces over OTLP.

This article shows how to combine them to trace an LLM application, and how to send the same traces to a general-purpose observability backend. It complements our pillar article on AI observability.

OpenLLMetry, maintained by Traceloop under the Apache 2.0 licence, provides OpenTelemetry instrumentations for many model providers (including Ollama and OpenAI-compatible APIs), vector databases (Chroma, Qdrant, Milvus…) and frameworks (LangChain, LangGraph, LlamaIndex, CrewAI…). The traceloop-sdk SDK enables them all at once; each instrumentation also exists as a separate package if you prefer to configure OpenTelemetry yourself.

The spans carry attributes inspired by the OpenTelemetry semantic conventions for generative AI ( gen_ai.*: requested model, input and output tokens, etc.). These conventions are still being stabilised: exact names may vary between versions.

Langfuse stores traces and presents them from an LLM angle: the call tree, full prompts and responses, estimated costs, user sessions, evaluation scores and user feedback. It can be self-hosted (the documentation describes Docker Compose and Kubernetes deployments) or used as a cloud service. Its OpenTelemetry entry point is /api/public/otel, using OTLP over HTTP (JSON or protobuf); according to the documentation, gRPC is not supported at present.

Langfuse is excellent for the team building the application. The operations team, however, wants to see LLM calls in the context of everything else: calling service, database, infrastructure, deployments. That is the role of a general-purpose OTLP-compatible backend such as Dynatrace. OpenTelemetry lets you feed both from a single instrumentation.

The Collector centralises secrets, lets you filter or mask sensitive attributes (prompts may contain personal data) and avoids coupling the application to a vendor.

pip install traceloop-sdk Enter fullscreen mode Exit fullscreen mode from traceloop. sdk import Traceloop from traceloop. sdk. decorators import workflow Traceloop. init ( app_name = "assistant-runbooks" ) @workflow ( name = "repondre_question" ) def repondre ( question: str ) -> str: # calls to the LLM, the retriever, etc.: instrumented automatically... Enter fullscreen mode Exit fullscreen mode The decorators ( workflow, task, agent, tool ) group the automatic spans under named steps. During development, the disable_batch=True option sends spans immediately.

The SDK reads its destination from environment variables. For a local Collector using OTLP/HTTP:

export TRACELOOP_BASE_URL = "http://otel-collector:4318" # do not collect the content of prompts and responses: export TRACELOOP_TRACE_CONTENT = false Enter fullscreen mode Exit fullscreen mode Check the exact behaviour of this variable and of TRACELOOP_HEADERS, as well as the privacy options, in the OpenLLMetry documentation.

receivers: otlp: protocols: http: endpoint: 0.0.0.0:4318 processors: batch: { } exporters: otlphttp/langfuse: endpoint: "https://langfuse.interne/api/public/otel" headers: Authorization: "Basic ${env:LANGFUSE_AUTH}" otlphttp/dynatrace: endpoint: "https://${env:DT_ENV_ID}.live.dynatrace.com/api/v2/otlp" headers: Authorization: "Api-Token ${env:DT_API_TOKEN}" service: pipelines: traces: receivers: [ otlp ] processors: [ batch ] exporters: [ otlphttp/langfuse, otlphttp/dynatrace ] Enter fullscreen mode Exit fullscreen mode LANGFUSE_AUTH is the base64 encoding of the Langfuse project’s public_key:secret_key. The Dynatrace token must have the permission to ingest OpenTelemetry traces. Langfuse may require additional headers depending on its version: the Langfuse documentation is the authority.

In Langfuse, each request appears as a trace with its generations, its estimated cost and the prompt content. In the observability backend, the same spans slot into the distributed trace of the calling service. To link the user click, the service and the LLM call cleanly, see end-to-end OpenTelemetry.

For agents that call tools via MCP, the same approach applies: see monitoring MCP agents with OpenTelemetry.

A few diagnoses become possible as soon as traces are in place:

The Langfuse SDK is the most direct route if Langfuse is the only destination. OpenLLMetry, or any standard OpenTelemetry instrumentation, is preferable if the traces must also feed other backends.

No. Langfuse focuses on the LLM application (prompts, costs, evaluations). Infrastructure, other services and SLOs remain the job of a general-purpose backend.

Yes. OpenLLMetry instruments, among others, the Ollama client and OpenAI-compatible APIs; on the server side, see monitoring Ollama for inference metrics.

Langfuse and OpenLLMetry make a coherent pair: standard instrumentation on one side, specialised analysis on the other, linked by OpenTelemetry. By adding a Collector in the middle, the same trace serves both the team improving the prompts and the team guaranteeing the reliability of the service.

span.observer is an independent community blog, not affiliated with Dynatrace LLC or with the projects mentioned. Trademarks belong to their respective owners. Tools change quickly: check commands and options in their official documentation.

Originally published on span.observer. French version: https://span.observer/fr/langfuse-openllmetry-observabilite-llm/.

Quelle: dev.to (dev.to). Original öffnen