OTEL: hook_execution_start telemetry events dropped before event logger initialized

Resolved 💬 1 comment Opened May 12, 2026 by cloudingenium-automation[bot] Closed Jun 11, 2026

Summary

With OTEL telemetry enabled (CLAUDE_CODE_ENABLE_TELEMETRY=1, OTEL_LOGS_EXPORTER=otlp), the extension fires hook_execution_start events ~37 ms BEFORE getOtlpLogExporters() finishes and the event logger is registered. The harness logs 3 [WARN] entries per session start:

[WARN] [3P telemetry] Event dropped (no event logger initialized): hook_execution_start
[WARN] [3P telemetry] Event dropped (no event logger initialized): hook_execution_start
[WARN] [3P telemetry] Event dropped (no event logger initialized): hook_execution_start

The dropped events are real hook lifecycle data (which hook fired, with what input, when) — losing them blinds session-start observability dashboards.

Environment

  • VS Code Insiders, extension Anthropic.claude-code v2.1.139
  • OTEL config:
  • CLAUDE_CODE_ENABLE_TELEMETRY=1
  • OTEL_LOGS_EXPORTER=otlp
  • OTEL_METRICS_EXPORTER=otlp
  • OTEL_TRACES_EXPORTER=otlp
  • OTEL_EXPORTER_OTLP_PROTOCOL=http/json
  • OTEL_EXPORTER_OTLP_ENDPOINT=https://<our-collector>/api/otel
  • Bearer token via OTEL_EXPORTER_OTLP_HEADERS
  • Hooks: 24 registered across SessionStart, InstructionsLoaded, PreToolUse, PostToolUse, ConfigChange, SessionEnd, PostCompactLog. Several async: true.
  • Observed 3 dropped events per session, consistently, across 5 sessions on 2026-05-12.

Evidence (from extension log timestamps)

2026-05-12T16:45:54.656Z [DEBUG] [Telemetry] enabled
2026-05-12T16:45:54.693Z [WARN] [3P telemetry] Event dropped (no event logger initialized): hook_execution_start
2026-05-12T16:45:54.710Z [DEBUG] [Telemetry] getOtlpLogExporters() called
2026-05-12T16:45:54.732Z [DEBUG] [Telemetry] Event logger registered

hook_execution_start at 54.693 ms fires in a 76 ms gap between "telemetry enabled" (54.656) and "logger registered" (54.732).

Reproducer

  1. Configure OTLP logs exporter with any reachable collector (or even an unreachable one — the drop happens client-side before the export attempt).
  2. Configure any hook bound to SessionStart or InstructionsLoaded in hooks.json.
  3. Open a new session; check the extension log:

``
grep "Event dropped (no event logger initialized)" \
~/.vscode-server*/data/logs/<latest>/exthost*/Anthropic.claude-code/Claude\ VSCode.log
``

  1. Expect 0 dropped events; observe 3.

Suggested fix

Move getOtlpLogExporters() + event-logger setup BEFORE the first PostHookExecutionEvent fires. Alternatively, buffer events emitted in the telemetry-enabled → logger-ready window and replay them when the logger registers. The buffer would only need to hold a handful of events (the gap is ~76 ms in practice) so memory cost is negligible.

If the gap is fundamentally hard to close (e.g. the exporter factory does I/O), a smaller stop-gap is to emit the drop count as a counter metric so consumers know how many events were lost rather than silently discarding them.

Why this matters for us

We're building a session-start latency dashboard that needs hook_execution_start to bin hook invocations against the SessionStart timeline. Losing the first 3 means we under-count hook frequency and miss the very hooks that run earliest (which are often the slowest, e.g. memory hydration, sync staleness check).

Happy to test any candidate fix.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗