claude-code - 💡(How to fix) Fix OTEL: hook_execution_start telemetry events dropped before event logger initialized

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

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.

Error Message

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 2026-05-12T16:45:54.693Z [WARN] [3P telemetry] Event dropped (no event logger initialized): hook_execution_start

Root Cause

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.

Code Example

[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

---

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

---

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

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
  4. 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.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix OTEL: hook_execution_start telemetry events dropped before event logger initialized