mikeaorlando.com Michael Orlando
  • Home
  • Start Here
  • About
  • Work & Ventures
  • Ideas & Writing
  • Collaborate
  • Search

◉LLM Observability with Langfuse

LLM Observability with Langfuse

One trace model for every LLM call, whichever client starts it, so a team can see which models run, for which workflow, at what token use, and where agents fail.

Routing Notes

  • Parent Projects for Fun
  • Signal Working Systems

Overview

The goal is that every LLM call is traced the same way, no matter which client starts it. Without that, each tool records its own version of events, the same call shows up twice or not at all, and nobody can answer a simple question like “which model did this workflow use, and what did it cost in tokens?”

I use Langfuse for this in customer work and in my own homelab, Praxis. This page describes the homelab setup, because it is the one I can show in detail: chat clients, an agent runtime, a model gateway and GPU image and video jobs all writing into one trace model.

Context

The homelab runs several things that call language models. Open WebUI and other chat clients serve people. Hermes Agent runs agent profiles that work in Jira and chat (see Taproot). LiteLLM is the single gateway in front of the local models (see local LLM serving), and some clients also call hosted providers directly. ComfyUI renders images and video on the GPU pool.

Each of these had some tracing, added at different times. The result was uneven: one client sent traces with sessions and tool calls, another sent traces with no names or sessions, and a call that passed through both a client and the gateway could be recorded twice, in two different projects. Logs had no trace IDs, so a trace and the gateway’s log line for the same request could not be joined.

The System

If terms like gateway, trace or generation are new to you, How my AI stack fits together explains how the parts relate.

The fix was to write down one contract and make every emitter follow it.

One trace model. A conversation is a session. One user turn, or one agent run, is a trace. Each real model call is exactly one generation inside that trace. Tool calls are observations in the same trace. All LLM traffic writes to one Langfuse project, because a trace and its observations can only nest inside a single project.

The component that calls the provider records the generation. This is the rule that prevents duplicates. A call through LiteLLM is recorded by LiteLLM’s callback. An agent calling a hosted provider directly is recorded by the agent’s own plugin. A chat client calling a provider directly is recorded by its pipeline filter. A client never records a generation for a call that goes through the gateway; it passes its session and trace IDs to the gateway in request metadata instead, and the gateway attaches them.

Emitters. There are four kinds:

  • the LiteLLM callback, for everything that reaches the gateway;
  • an Open WebUI pipeline filter, for chats that go straight to a hosted provider;
  • the Hermes Langfuse plugin, enabled in every agent profile, with session, turn and tool detail;
  • GPU job records: each finished ComfyUI render or training job writes a trace with its workflow, models and run time, next to the LLM traces.

Correlation with logs. Trace, session and request IDs go into JSON fields of the gateway’s log line in Loki, not into labels. From a trace you can find the log line, and from the log line you can find the trace.

Agents can read their own traces. Langfuse exposes an MCP endpoint, so Claude Code can read traces directly while it debugs a problem. Hermes goes a step further: a self-improvement loop reads its own recent traces, and when a skill needed correction during a run, it writes a score on that trace. That turns a behavior that used to leave only a file edit into data that can be queried and trended. Secrets are redacted from tool arguments before they are stored, because the agent’s tools touch real credentials.

Components and Why I Chose Them

Component What it does here Why I chose it
Langfuse (tool page) Stores and displays every trace Open source and self-hostable, with a model for sessions, traces and generations that fits both chat and agents. Most of the components I run already had a Langfuse integration, and it exposes an MCP endpoint that agents can read.
LiteLLM callback (tool page) Records every call that goes through the gateway It is built into the gateway, so every client behind it is traced without changes to the client.
Open WebUI Pipelines filter (tool page) Records chats that go straight to a hosted provider Open WebUI’s Pipelines project includes a Langfuse filter, so those calls are traced without changing Open WebUI itself.
Hermes Agent Langfuse plugin (tool page) Records agent turns, sessions and tool calls It is the agent’s own plugin, so it sees session, turn and tool detail that a gateway cannot see.
Loki (tool page) Holds the gateway’s log lines with trace IDs in JSON fields It was already the homelab’s log store. IDs go in the log line, not in labels, because every distinct label value creates a new log stream.
Grafana (tool page) Shows the logs and metrics next to each other It already reads Loki and Prometheus in the homelab.

Outcomes

The trace store now answers the questions a team actually asks about LLM use: which models are in use, by which workflow or client, at what token use, and where agent runs fail or need correction. A generation appears once, in one place, with the same fields whichever client started it. GPU jobs and LLM calls sit side by side, so image and video work is visible in the same view as chat and agent work.

Example Trace Structure

This is a simplified, illustrative shape of one agent conversation in the trace model. The names and values are placeholders.

session: example-chat-id                     one conversation
├── trace: "Agent turn"                      one user turn or agent run
│   ├── tags: client:example-client, model:example-model
│   ├── generation: example-model            one real model call
│   │   ├── metadata: requested_model, resolved_model, think
│   │   └── usage: input, output and reasoning tokens
│   ├── tool observation: example-tool       arguments redacted before storage
│   └── generation: example-model            the call after the tool result
└── trace: "Agent turn"                      the next turn in the same session
    └── generation: example-model

The matching gateway log line carries the same IDs as JSON fields:

{"trace_id": "example-trace-id", "session_id": "example-chat-id", "request_id": "example-request-id", "model": "example-model"}

Patterns Worth Reusing

Decide who records the generation before adding any tracing. Most duplicate and missing traces come from two components each assuming the other one records the call, or both recording it.

Carry correlation IDs in request metadata and log fields. This works without changing upstream code and without OpenTelemetry propagation that the components on the path do not support.

Run the trace store like any other stateful service. Three lessons were general enough to repeat:

  • Pin the image versions of its database dependencies, so a database changes only when someone chooses to upgrade it.
  • Set retention on purpose. The default keeps everything indefinitely.
  • Check that every emitter is actually sending. A health check can stay green while nothing new is stored; the only proof is a fresh trace from each emitter, and a check that flags an emitter that goes quiet while its service is still handling requests.

The practical result for a team: before adding more models or agents, get one trace model and one recording rule in place. Every later question about cost, usage or failure depends on it.

Explore

  • ✎Posts
  • ○Categories
  • ◉Projects for Fun
  • ▶Projects for Work
  • ◎Systems Across Domains
  • ▪Technical Tools
  • ◆Transferable Skills
  • ✕Value Multipliers
  • ◇Ventures

Michael Orlando

Systems, ventures, writing, and public proof arranged so the right people can find the right next step.

© 2026 Michael Orlando

Privacy & Data Handling

about.me Substack Credly Polywork