feat(telemetry): add export command#953
Open
EhabY wants to merge 7 commits into
Open
Conversation
35eba99 to
821a950
Compare
18ab98f to
5523f85
Compare
821a950 to
728e014
Compare
728e014 to
c450036
Compare
c450036 to
4daf2f8
Compare
ab7dcf4 to
acadd7e
Compare
4daf2f8 to
9534418
Compare
5ee4862 to
539131f
Compare
…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.
539131f to
fe6675e
Compare
9534418 to
25db18c
Compare
25db18c to
d70fc4b
Compare
fe6675e to
94ac895
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
coder.exportTelemetrycommand UI flowCommandManagerand package contributionsCloses #903.
Follow-up: #952 tracks adding recent local telemetry to support bundles.
Stack: 4 / 4. Base: #961.
Review follow-up
TelemetryService.flush()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.tspnpm test:extensionpnpm typecheckpnpm lintpnpm format:checkpnpm buildGenerated by Coder Agents.