Summary
Claude Code's hook input JSON carries a prompt_id field (v2.1.196+) that matches the prompt.id attribute on real OpenTelemetry events (per https://code.claude.com/docs/en/hooks, fetched 2026-07-22). This would let external tooling correlate a hook's local hook-telemetry envelope entry with the same turn's real OTel stream — currently the envelope (schema_version: "1.0", lib/hook-utils.sh:391 hook::emit_telemetry) has no such field.
Why deferred from #836
#836 (hook-observability: statusMessage/systemMessage/telemetry adoption) found this while researching fresh hooks docs, but adding it is a hook-telemetry schema change (schema_version 1.0 → 1.1), not a hook-observability concern, and touches every producer's data_json construction (~25 call sites) — a distinct, complete sweep of its own rather than a partial addition riding along #836's unrelated scope.
Scope (when picked up)
- Bump
hook-telemetry's schema_version to 1.1, add prompt_id to the envelope (either a new optional parameter on hook::emit_telemetry, defaulting empty/omitted for backward compatibility, or captured inside each producer's data object).
- Update every producer hook (all wired
plugins/*/hooks/*.sh — see docs/conventions/hook-telemetry/README.md's Implementers table) to extract prompt_id from its buffered stdin JSON and pass it through, so the field is uniformly populated across the fleet — a partial rollout would be indistinguishable from "prompt_id genuinely absent, pre-first-input" per the docs, which defeats the point.
- Document the correlation mechanism and the
OTEL_* env-var-stripping rationale (why hooks can't emit real OTel directly) in docs/conventions/hook-telemetry/README.md.
Related
Summary
Claude Code's hook input JSON carries a
prompt_idfield (v2.1.196+) that matches theprompt.idattribute on real OpenTelemetry events (per https://code.claude.com/docs/en/hooks, fetched 2026-07-22). This would let external tooling correlate a hook's localhook-telemetryenvelope entry with the same turn's real OTel stream — currently the envelope (schema_version: "1.0",lib/hook-utils.sh:391hook::emit_telemetry) has no such field.Why deferred from #836
#836 (hook-observability: statusMessage/systemMessage/telemetry adoption) found this while researching fresh hooks docs, but adding it is a
hook-telemetryschema change (schema_version1.0 → 1.1), not ahook-observabilityconcern, and touches every producer'sdata_jsonconstruction (~25 call sites) — a distinct, complete sweep of its own rather than a partial addition riding along #836's unrelated scope.Scope (when picked up)
hook-telemetry'sschema_versionto1.1, addprompt_idto the envelope (either a new optional parameter onhook::emit_telemetry, defaulting empty/omitted for backward compatibility, or captured inside each producer'sdataobject).plugins/*/hooks/*.sh— seedocs/conventions/hook-telemetry/README.md's Implementers table) to extractprompt_idfrom its buffered stdin JSON and pass it through, so the field is uniformly populated across the fleet — a partial rollout would be indistinguishable from "prompt_id genuinely absent, pre-first-input" per the docs, which defeats the point.OTEL_*env-var-stripping rationale (why hooks can't emit real OTel directly) indocs/conventions/hook-telemetry/README.md.Related