Skip to content

refactor(telemetry): OTel-format ids and explicit session id#935

Merged
EhabY merged 1 commit intomainfrom
telemetry/schema-cleanup
May 7, 2026
Merged

refactor(telemetry): OTel-format ids and explicit session id#935
EhabY merged 1 commit intomainfrom
telemetry/schema-cleanup

Conversation

@EhabY
Copy link
Copy Markdown
Collaborator

@EhabY EhabY commented May 5, 2026

Follow-up to #934 cleaning up the JSONL schema.

  • session_id was vscode.env.sessionId verbatim (UUID + ms timestamp, looks malformed); event_id / trace_id were UUIDv4, not OTel hex.
  • New src/telemetry/ids.tsnewTraceId / newSpanId / newSessionId (32 / 16 / 32 hex, OTel widths).
  • TelemetryService now takes a built SessionContext instead of ExtensionContext, removing the as unknown as test fixtures. ServiceContainer builds it once and threads sessionId to both the sink filename and the event payload.

Also folds in #934 review feedback: tightened a couple of comments and moved coder.{tasks,chat}.refresh registrations adjacent to their panel providers.

Stacked on #934. Retarget once that lands.

@EhabY EhabY self-assigned this May 5, 2026
@EhabY EhabY force-pushed the telemetry/command-dispatcher branch from 4b4c555 to 0e6d1a1 Compare May 5, 2026 13:57
@EhabY EhabY force-pushed the telemetry/schema-cleanup branch 2 times, most recently from 6601664 to 4173350 Compare May 6, 2026 14:20
@EhabY EhabY requested a review from DanielleMaywood May 6, 2026 15:56
@EhabY EhabY force-pushed the telemetry/command-dispatcher branch from 2f905d8 to e351ef2 Compare May 7, 2026 09:17
Base automatically changed from telemetry/command-dispatcher to main May 7, 2026 09:33
@EhabY EhabY force-pushed the telemetry/schema-cleanup branch from 4173350 to ae9a91b Compare May 7, 2026 09:34
Comment thread src/core/container.ts Outdated
The local JSONL output exposed two schema rough edges. First, session_id
was vscode.env.sessionId verbatim, which is a UUID concatenated with a
ms timestamp ("0f465473-...-bed92cb4ed3a1777982179036"), looking like a
malformed UUID. Second, event_id and trace_id were UUIDv4 with hyphens,
not the lowercase-hex form OTel uses, so a future exporter would need a
translation layer for no real reason.

- Add src/telemetry/ids.ts with newTraceId (16 bytes / 32 hex),
  newSpanId (8 bytes / 16 hex), and newSessionId (16 bytes / 32 hex).
  Names and widths match OTel.
- buildSession takes sessionId as a parameter instead of reading
  vscode.env.sessionId, decoupling our schema from VS Code's quirks.
- TelemetryService accepts sessionId in its constructor and forwards
  it to buildSession.
- ServiceContainer generates one sessionId via newSessionId() and
  threads it to both LocalJsonlSink (filename slug) and TelemetryService
  (event payload), so the on-disk filename and the session_id field
  always match.
- service.ts: replace crypto.randomUUID() with newSpanId / newTraceId
  at every event emission.
- Tests updated for the new sessionId parameter and the new id format
  regex (/^[0-9a-f]{16}$/ for event_id, sessionId is now an explicit
  test fixture).

trace_id stays on every event (including single-event "traces"). You
cannot know at emit time whether a phase child will follow, and a
consistent schema is more valuable to consumers than 36 bytes per
event.
@EhabY EhabY force-pushed the telemetry/schema-cleanup branch from ae9a91b to 61ce9e6 Compare May 7, 2026 10:22
@EhabY EhabY merged commit ae1920a into main May 7, 2026
10 checks passed
@EhabY EhabY deleted the telemetry/schema-cleanup branch May 7, 2026 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants