Skip to content

feat(telemetry): add export command#953

Open
EhabY wants to merge 7 commits into
feat/issue-903-export-telemetry-otlp-writerfrom
feat/issue-903-export-telemetry
Open

feat(telemetry): add export command#953
EhabY wants to merge 7 commits into
feat/issue-903-export-telemetry-otlp-writerfrom
feat/issue-903-export-telemetry

Conversation

@EhabY
Copy link
Copy Markdown
Collaborator

@EhabY EhabY commented May 13, 2026

Summary

  • add the coder.exportTelemetry command UI flow
  • register the command through CommandManager and package contributions
  • connect date-range selection, format selection, save dialog, export progress, and telemetry flushing

Closes #903.
Follow-up: #952 tracks adding recent local telemetry to support bundles.

Stack: 4 / 4. Base: #961.

Review follow-up

  • adds TelemetryService.flush()
  • flushes buffered local telemetry before discovering and reading telemetry files so recent events are included

Validation

  • pnpm test:extension ./test/unit/telemetry/export/range.test.ts ./test/unit/telemetry/export/files.test.ts ./test/unit/telemetry/export/writers.test.ts ./test/unit/core/commandManager.test.ts
  • pnpm test:extension
  • pnpm typecheck
  • pnpm lint
  • pnpm format:check
  • pnpm build

Generated by Coder Agents.

@EhabY EhabY self-assigned this May 13, 2026
@EhabY EhabY force-pushed the feat/issue-903-export-telemetry branch from 35eba99 to 821a950 Compare May 13, 2026 14:37
@EhabY EhabY force-pushed the feat/issue-906-auth-workspace-telemetry branch 5 times, most recently from 18ab98f to 5523f85 Compare May 15, 2026 10:01
@EhabY EhabY force-pushed the feat/issue-903-export-telemetry branch from 821a950 to 728e014 Compare May 15, 2026 10:06
@EhabY EhabY changed the base branch from feat/issue-906-auth-workspace-telemetry to main May 15, 2026 10:06
@EhabY EhabY force-pushed the feat/issue-903-export-telemetry branch from 728e014 to c450036 Compare May 17, 2026 17:09
@EhabY EhabY changed the title feat(telemetry): export local telemetry feat(telemetry): add export command May 17, 2026
@EhabY EhabY changed the base branch from main to feat/issue-903-export-telemetry-otlp-writer May 17, 2026 17:10
@EhabY EhabY force-pushed the feat/issue-903-export-telemetry branch from c450036 to 4daf2f8 Compare May 17, 2026 19:42
@EhabY EhabY force-pushed the feat/issue-903-export-telemetry-otlp-writer branch from ab7dcf4 to acadd7e Compare May 17, 2026 19:42
@EhabY EhabY force-pushed the feat/issue-903-export-telemetry branch from 4daf2f8 to 9534418 Compare May 18, 2026 17:03
@EhabY EhabY force-pushed the feat/issue-903-export-telemetry-otlp-writer branch 4 times, most recently from 5ee4862 to 539131f Compare May 19, 2026 11:02
EhabY added 6 commits May 20, 2026 13:27
…ugh types

- Consolidate preset labels/details/filenames/durations into one PRESETS
  record so TELEMETRY_RANGE_PRESETS and createPresetDateRange stay in sync.
- Derive TelemetryRangePresetId from PRESET_IDS; un-export parseUtcDate and
  utcDateString (used only internally).
- Drop src/telemetry/export/types.ts; consumers import TelemetryEvent
  directly. JsonValue/JsonPrimitive are unused here and will be introduced
  by the OTLP writer branch where they're actually needed.
- Flatten the nested ternary in errorMessage.
Extract `src/telemetry/wireFormat.ts` as the single source of truth for the
on-disk JSONL shape. `SessionContext`, `TelemetryContext`, and
`TelemetryEvent` are now `DeepReadonly<z.infer<...>>` derived from the
schemas, removing the parallel hand-written interfaces and the satisfies
drift checks. The sink and exporter both share `serializeTelemetryEvent`
and `parseTelemetryEventLine`, so the format can't drift between writer
and reader.

Export-side cleanups in `files.ts` and `range.ts`: hide internal helpers,
rename `segment`/`sessionSlug` to `part`/`session`, drop the next-day
grace in `fileDateCanContainRangeEvent`, simplify presets, and replace
the manual snake/camel mapping with a tiny generic rename. Tests for the
parse boundary moved to `wireFormat.test.ts`; the remaining files tests
focus on listing and streaming, now backed by memfs.
Move `tempFilePath` and `renameWithRetry` from `src/util.ts` into a
focused `src/util/fs.ts`, alongside a new `writeAtomically(path, write)`
helper that captures the temp-file + rename + best-effort cleanup
pattern previously copy-pasted into the telemetry writer and
`CliCredentialManager.atomicWriteFile`. Both call sites now use the
shared helper; the SSH config / support bundle / CLI manager keep their
bespoke flows and just update imports.

Rewrite `writeJsonArrayExport` to stream chunks through
`Readable.from(...)` into `createWriteStream` via `stream/promises`
`pipeline`. Memory stays flat regardless of `maxTotalBytes`, which has
no enforced ceiling and can comfortably exceed the default 100 MB cap.

Tests for `tempFilePath` and `renameWithRetry` move into
`test/unit/util/fs.test.ts` alongside a new `writeAtomically` suite
covering success, partial-write rollback, and callback return values.
@EhabY EhabY force-pushed the feat/issue-903-export-telemetry-otlp-writer branch from 539131f to fe6675e Compare May 20, 2026 10:29
@EhabY EhabY force-pushed the feat/issue-903-export-telemetry branch from 9534418 to 25db18c Compare May 20, 2026 10:30
@EhabY EhabY force-pushed the feat/issue-903-export-telemetry branch from 25db18c to d70fc4b Compare May 20, 2026 10:45
@EhabY EhabY force-pushed the feat/issue-903-export-telemetry-otlp-writer branch from fe6675e to 94ac895 Compare May 20, 2026 13:50
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.

Telemetry: coder.exportTelemetry command (Logs, Traces, and Metrics OTLP/JSON)

1 participant