The Langfuse Plugin for Claude Code, Side by Side with OTel, and Behind an Egress Proxy
In the last post I got Claude Code’s own OpenTelemetry traces into a self-hosted Langfuse, with a small collector config to put prompts and tool output where Langfuse shows them. The one thing missing was Claude’s replies. Langfuse’s plugin rebuilds turns from the session transcript instead, so I installed it next to the OTel setup, sent both into the same project, and compared them. Then I worked out how to roll the plugin out in a shared dev image where Langfuse sits behind an egress proxy.
Installing it
claude plugin marketplace add langfuse/Claude-Observability-Plugin
claude plugin install langfuse-observability@langfuse-observability
Then /plugin configure langfuse-observability@langfuse-observability asks for three values. For the local Docker stack from the last post:
LANGFUSE_BASE_URL:http://localhost:3000, the web app, with no/apipathLANGFUSE_PUBLIC_KEY:pk-lf-localLANGFUSE_SECRET_KEY:sk-lf-local
The secret goes into the macOS keychain. The other options land in ~/.claude/settings.json under pluginConfigs, so don’t worry when the secret isn’t in there. /reload-plugins picks up the change.
The plugin registers its own Stop and SessionEnd hooks. Langfuse’s page also describes adding a hook to settings.json by hand, along with a TRACE_TO_LANGFUSE switch. That’s the older, non-plugin install. The plugin doesn’t need it and doesn’t read that variable. Do both and you’d send every turn twice.
The docs say you need Python 3.9+ and pip install langfuse. If uv is on your PATH, you don’t: the hook runs as uv run --script, and the script declares its own langfuse dependency inline. Only without uv does it fall back to python3 and whatever packages that has.
It runs one turn behind
The hook doesn’t send the turn that just finished. It holds it (“Holding trailing open turn … until a new user row closes it”) and sends it after your next message, once the turn can’t grow any more. The SessionEnd hook sends the last held turn when you exit or /clear. If Claude Code is killed instead of exiting cleanly, that last turn is lost.
Failures are silent
My first configure put the public key in the secret field too. Langfuse rejected every export, and the hook’s log said this after every turn:
[INFO] Processed 1 turns in 0.17s (session=...)
Turning on CC_LANGFUSE_DEBUG didn’t help. Export happens in a background flush that swallows exceptions, so a 401 never reaches the log, and the Langfuse web container doesn’t log requests either. What found it was running the hook by hand against the session transcript with known-good keys passed as environment variables. That run landed, so the stored secret was the only difference. The log is ~/.claude/state/langfuse_hook.log. If it says turns were processed and nothing shows up in Langfuse, suspect the keys first.
OTel vs. the plugin, side by side
Both routes wrote into the same project, so I compared them turn for turn. The plugin’s spans are Conversational Turn, LLM Call, and Tool: <name>, and OTel’s are claude_code.interaction, claude_code.llm_request, claude_code.tool.*, and the tool spans.
| OTel + collector | Plugin | |
|---|---|---|
| Your prompt | ✅ | ✅ |
| Claude’s reply text | ⚠️ only with the logs bridge, as a sibling span | ✅ on the turn and every LLM call |
| What the model was sent | ❌ just repl_main_thread |
✅ full message history (~50k chars per call here) |
| Model, tokens, cost | ✅ | ✅ same numbers |
| Tool inputs and outputs | ✅ | ✅ |
| Permission-wait vs. execution timing, request ID, stop reason | ✅ | ❌ one span per tool |
| Git branch, project | ❌ | ✅ |
| Thinking text | ❌ redacted | ⚠️ only what the transcript keeps, usually nothing |
| Your email and account IDs | ✅ automatic | only if you set a user ID |
| When it arrives | live, mid-turn | one turn late |
On their own, OTel spans don’t carry the reply: none of the roughly 1,800 claude_code.llm_request spans from five days of local use had response.model_output. The last post ends with a collector bridge that turns Claude Code’s raw-response log events into spans, which recovers the replies. The plugin still has the edge on what the model was sent, and it puts the reply right on the generation instead of beside it.
My take: the plugin is for reading conversations, meaning what Claude saw and why it did what it did. OTel is for operations: live latency, how long people sit on permission prompts, and request IDs to match against API logs. Running both costs nothing locally. On a shared deployment I’d pick the plugin for content and keep OTel only if someone wants the timing.
Rolling it out in a shared image
Paired with Devsy (formerly DevPod) to spin up workspaces (see the earlier OpenSWE + DevPod + Aegra posts) in a shared image:
Environment variables beat plugin options. For each setting the hook checks the plain variable (LANGFUSE_PUBLIC_KEY, LANGFUSE_SECRET_KEY, LANGFUSE_BASE_URL, LANGFUSE_USER_ID) before the configured option, and Claude Code passes its environment to hooks. Install and enable the plugin in the image, then set the variables. Set all of them the same way: the hook warns when keys and URL come from different sources, because a mismatched pair fails silently.
The keys are only ever an HTTP header. The SDK posts OTLP to {LANGFUSE_BASE_URL}/api/public/otel/v1/traces with:
Authorization: Basic base64("<public_key>:<secret_key>")
x-langfuse-public-key: <public_key>
Nothing is signed or checked locally, so a proxy can swap the header. The workspace sets both keys to a placeholder like proxy-injected, and the proxy replaces Authorization with the real value on the way out. The placeholders have to be non-empty, because the hook turns itself off if either key is missing. Set LANGFUSE_BASE_URL to whatever the proxy intercepts. If it’s unset, the plugin quietly defaults to https://cloud.langfuse.com.
User identity has to be set, not discovered. OTel spans carry your Claude account email automatically. The plugin only sends a user if LANGFUSE_USER_ID is set, and it’s a fixed string. It doesn’t read who’s logged into Claude Code, and a workspace start script runs before anyone logs in anyway. So set it at workspace start from whatever identity the workspace has. A start script can write it into the env block of ~/.claude/settings.json, which also covers claude launched from an IDE:
email="$(git config --global user.email)"
f=~/.claude/settings.json; [ -f "$f" ] || echo '{}' > "$f"
jq --arg e "$email" '.env.LANGFUSE_USER_ID = $e' "$f" > "$f.tmp" && mv "$f.tmp" "$f"
Decide about media. CC_LANGFUSE_CAPTURE_IMAGES is on by default. It uploads pasted screenshots and image tool results so they render in the trace. An upload is two requests: POST {BASE_URL}/api/public/media (through the proxy, same auth), then a PUT straight to the presigned blob-storage URL Langfuse hands back. That storage host has to be reachable through egress, or the images just won’t appear. If you don’t want screenshots of people’s screens in a shared Langfuse, set it to false and the trace shows a short text marker instead.
Test the proxy without the hook. curl -u proxy-injected:proxy-injected {BASE_URL}/api/public/projects should return 200, which means the injection works. Check this first, because the hook won’t tell you if it doesn’t.
One more thing before turning this on for a team: the plugin sends full conversation text, including everything the model was sent. Use it for automated agent runs, but make sure people are aware of it and agree before capturing their individual agent conversations.
Claude Code and Opus 5.5 were instrumental in investigating functionality and drafting this post.
Copyright 2026 Wendy Smoak - This post first appeared on wsmoak.net and is CC BY-NC licensed.