feat: emit custom-title and agent-name as OTLP telemetry events
Summary
custom-title and agent-name session metadata are currently written only to the local .jsonl session file and never emitted as OTLP telemetry. This makes them invisible to any OpenTelemetry-based observability pipeline.
Current behavior
When a session is renamed (via /rename) or a sub-agent is spawned with a name, Claude Code appends entries like these to the local session file:
{"type":"custom-title","customTitle":"clip-research","sessionId":"3a378729-d860-4d1a-95ca-0d297d7c7f4f"}
{"type":"agent-name","agentName":"clip-research","sessionId":"3a378729-d860-4d1a-95ca-0d297d7c7f4f"}
These are not forwarded to the configured OTLP exporter (OTEL_EXPORTER_OTLP_ENDPOINT). Querying a BigQuery-backed OTLP collector that receives all other claude_code.* events (user_prompt, api_request, tool_result, tool_decision, api_error, etc.) returns zero rows for these two types.
Desired behavior
Emit both values as OTLP log records (consistent with existing claude_code.* events), e.g.:
event.name = "claude_code.custom_title"
session.id = <sessionId>
custom_title = <customTitle>
event.name = "claude_code.agent_name"
session.id = <sessionId>
agent_name = <agentName>
Use case
Session titles and agent names are essential dimensions for understanding Claude Code usage in multi-agent / parallel-worktree workflows:
- Session titles (
/rename) let users label what a session was for — without them, analytics can only show opaque session IDs. - Agent names identify which sub-agent in a parallel workflow produced which API calls, tool decisions, and token costs.
Both are already collected client-side; the only missing piece is forwarding them through the OTLP pipeline so downstream collectors and BigQuery/Grafana dashboards can group and filter by them.
Environment
- Claude Code version: 2.1.112
- Platform: macOS (darwin arm64)
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗