CLAUDE LABJP
FORK — Claude Code 2.1.212 changes what /fork does: it copies your conversation into a new background session with its own row in claude agents, so you can keep working. The old in-session subagent is now /subtaskLIMITS — WebSearch calls are now capped at 200 per session by default, and subagent spawns get the same 200 ceiling, so a runaway search or delegation loop stops on its ownMCPBG — MCP tool calls running past two minutes now move to the background automatically, keeping the session usable. Tune the threshold with CLAUDE_CODE_MCP_AUTO_BACKGROUND_MSPLANFIX — Fixed plan mode auto-running file-modifying Bash commands such as touch and rm without a permission prompt or an SDK canUseTool callbackSONNET5 — Claude Sonnet 5 is running on introductory pricing of $2 per million input tokens and $10 per million output. After August 31 it moves to $3 and $15IPO — Bankers are reportedly lining up investor meetings for Anthropic ahead of a possible public listing as soon as OctoberFORK — Claude Code 2.1.212 changes what /fork does: it copies your conversation into a new background session with its own row in claude agents, so you can keep working. The old in-session subagent is now /subtaskLIMITS — WebSearch calls are now capped at 200 per session by default, and subagent spawns get the same 200 ceiling, so a runaway search or delegation loop stops on its ownMCPBG — MCP tool calls running past two minutes now move to the background automatically, keeping the session usable. Tune the threshold with CLAUDE_CODE_MCP_AUTO_BACKGROUND_MSPLANFIX — Fixed plan mode auto-running file-modifying Bash commands such as touch and rm without a permission prompt or an SDK canUseTool callbackSONNET5 — Claude Sonnet 5 is running on introductory pricing of $2 per million input tokens and $10 per million output. After August 31 it moves to $3 and $15IPO — Bankers are reportedly lining up investor meetings for Anthropic ahead of a possible public listing as soon as October
Articles/Claude Code
Claude Code/2026-04-29Advanced

Observability for Claude Code with OpenTelemetry — A Production-Grade Tracing Guide for Agentic Workflows

Trace Claude Code agent runs end to end with OpenTelemetry. Hook integration, per-tool spans, MCP propagation, cost attribution, and sampling patterns that survive thousands of runs per day.

observability20opentelemetry2claude-code129production111tracing2monitoring9

Premium Article

The first thing you discover when you start running Claude Code agents in production is that you're flying half-blind. /cost tells you what the session burned in total, but it won't tell you which tool call took 12 seconds, which MCP server retried four times, or where the loop started spinning. The session log scrolls past faster than you can read it.

I learned this the hard way. One morning my agent latency doubled overnight. The culprit turned out to be a single MCP server stuck on a network read, but it took me half a day to find that out by hand. With OpenTelemetry in place, I would have seen it the moment I opened the trace.

This guide walks through wiring Claude Code into OpenTelemetry so production runs become traceable, bottlenecks become obvious, and cost regressions become attributable to the specific tool call that caused them. We'll move from a minimal SDK setup to hook-based span emission, MCP context propagation, sampling that survives real traffic, and the dashboards worth keeping open every morning.

Why instrument Claude Code in the first place

Agent execution looks nothing like a normal request/response service. A single session can chain dozens of tool invocations, each fanning out to MCP servers and external APIs, with retry loops layered on top for self-correction. Trying to debug that with logs alone is the same pain you feel when you debug distributed systems with print statements.

In my experience, instrumentation buys you three concrete wins. First, bottlenecks become visible in seconds rather than hours. Second, cost regressions can be traced down to the project, the tool, and even the prompt shape that triggered them. Third, retry storms — those quiet, invisible loops that drain your monthly bill — start showing up the day they begin, not the week the invoice arrives.

Pick your signals before you pick your tools

OpenTelemetry has three signal types, and the temptation is to enable everything and figure it out later. Resist it. Decide upfront what each signal is for.

  • Traces capture one agent run as one trace, with parent/child spans modeling the call tree. This is the centerpiece for Claude Code observability
  • Metrics roll up time-series aggregates: invocation count, p50/p95 latency, error rate, token consumption. Use these for dashboards and alerts, not detective work
  • Logs capture per-event detail: the actual prompt, the actual stack trace. Necessary for drill-down, but you cannot afford to store every prompt forever — sampling and retention policies matter

The pragmatic split is traces in the middle, metrics around them for trend monitoring, and logs as the deep-dive layer when something breaks. The rest of this guide focuses on traces and treats metrics and logs as supporting cast.

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
Working code that stitches Claude Code hooks, MCP calls, and tool invocations into a single trace — in both Node.js and Python
A Tail-Based sampling + metrics setup that cuts storage 80-90% while never dropping errors or slow traces
A 5-step runbook for when traces don't show up, plus the operational insight that caught a 40%+ monthly cost overrun the next Monday
Secure payment via Stripe · Cancel anytime

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Claude Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • Copy-paste ready implementation code
  • New advanced guides published daily
  • $5/mo or $10 for lifetime access
View Membership →

Related Articles

API & SDK2026-03-27
Building AI Application Observability with Claude API and OpenTelemetry
Learn how to integrate OpenTelemetry with your Claude API applications for unified tracing, metrics, and logging. Covers token usage visualization, latency monitoring, cost alerting, and distributed tracing for agent workflows.
Claude Code2026-04-24
Debugging Claude Code Hooks in Production — Where to Start When Logs Are Missing
Your Claude Code hooks work locally but go silent in production. Here is the three-layer observability pattern I use on real projects, plus a 60-second minimal reproduction recipe for isolating failures.
Claude Code2026-07-09
Is the Draft That Passed the Gate the Same One You Published?
In unattended pipelines, the file your quality gate inspected and the file you actually publish can quietly diverge. Here is a digest-bound gate receipt design, with working code and measured results from 180 days of running it.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →