Skip to content

feat(conventions): add prompt_id correlation to the hook-telemetry envelope #930

Description

@kyle-sexton

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

Metadata

Metadata

Assignees

Labels

needs-humanHuman-in-the-loop required; autonomous sessions must not resolve items carrying this.priority: mediumReal value, no hard deadline; normal backlog flow.status: readyTriaged, unblocked, and fully specified; eligible to pick up.

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions