Skip to content

feat: Add Claude Code telemetry to a recorded session: tool times, permission waits, call labels, retries #1924

Open

Description

@michaljacovi

Part of #1920.

Problem

The proxy sees the wire but not what happens on the client between calls:

  • Tool time is inferred from the response that asked for the tools to the
    next request (timeline.go:126). Parallel tools all get the same window:
    on one real session, 3 parallel tools each showed 9.8 s, though they took
    5.9, 1.4 and 4.5 s.
  • Permission waits are not visible at all.
  • Side calls (session title, prompt suggestion, away summary) show as main.
  • Retries are separate rows that can't be told apart from new calls:
    X-Stainless-Retry-Count was 0 on all 59 rows of a session with retries,
    because Claude Code retries outside the SDK counter.

Claude Code's own OpenTelemetry has all four: tool and tool.execution
spans, tool.blocked_on_user (permission waits), query_source (main,
subagent, side call) and attempt.

Proposal

  • Join the telemetry to the recorded session. Session id is the same on both
    sides (X-Claude-Code-Session-Id = the spans' session.id). Tool spans
    join exactly by tool_use id, which matched on 42 of 42 tools in our test.
    Model-call spans join by session id plus start order and time, because
    Claude Code sends no traceparent.
  • Mark the joined data with the SessionEvent.Source field from feat: Add the shared transcript import path to the session archive and cost ledger #1876, so
    wire facts and telemetry facts stay apart.
  • Use it in the timeline: real tool spans, permission waits, labels and
    retry attempts. Keep the inferred times when no telemetry is present.

Open questions

Out of scope

  • Telemetry from agents other than Claude Code.
  • A remote telemetry backend.

Assisted-By: Claude (Anthropic AI) noreply@anthropic.com

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestlaptopThe local (laptop) tool: install, abctl, the numbers

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions