Add telemetry for Interactive Shell, Query Playground, and cross-feature navigation#601
Conversation
Co-authored-by: Copilot <copilot@github.com>
…ension Co-authored-by: Copilot <copilot@github.com>
…takes section Co-authored-by: Copilot <copilot@github.com>
There was a problem hiding this comment.
Pull request overview
This PR adds telemetry instrumentation across the new 0.8.0 Interactive Shell, Query Playground, Collection View completions, and cross-feature navigation flows, enabling usage analytics and health signals without capturing user query content.
Changes:
- Instrument shell + playground execution with session lifecycle telemetry, command classification, and connection correlation.
- Add completion-acceptance telemetry in both VS Code completions (playground) and Monaco (Collection View) paths.
- Add activation-source telemetry via dedicated
.inlinecommand IDs and navigation-specific events.
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| src/webviews/query-language-support/registerLanguage.ts | Adds Monaco command wiring to report completion acceptance back to the extension host. |
| src/webviews/query-language-support/completions/createCompletionItems.ts | Attaches completion-acceptance command to generated Monaco completion items + maps kind→category. |
| src/webviews/documentdb/collectionView/components/queryEditor/QueryEditor.tsx | Passes completion-accepted callback to language registration and routes via tRPC. |
| src/webviews/documentdb/collectionView/collectionViewRouter.ts | Adds telemetry properties for toolbar-driven navigation + new completionAccepted mutation. |
| src/utils/classifyCommand.ts | New utility to classify shell/playground commands into telemetry-safe categories. |
| src/documentdb/shell/ShellTerminalLinkProvider.ts | Adds activationSource telemetry for shell action-line navigation links. |
| src/documentdb/shell/DocumentDBShellPty.ts | Adds shell session start/end + per-eval telemetry (category, index, result type, correlation). |
| src/documentdb/query-language/playground-completions/PlaygroundCompletionItemProvider.ts | Adds completion-acceptance command on VS Code completion items (playground). |
| src/documentdb/playground/WorkerSessionManager.ts | Adds worker lifecycle telemetry (spawn count, lifetime, termination events). |
| src/documentdb/ClustersExtension.ts | Registers new inline command IDs and internal completionAccepted telemetry command. |
| src/commands/playground/scanCollectionSchema.ts | Records schema scan results in telemetry measurements. |
| src/commands/playground/playgroundOpenInShell.ts | Adds activationSource telemetry for CodeLens-driven navigation to shell. |
| src/commands/playground/playgroundOpenInCollectionView.ts | Adds activationSource + hasFilter telemetry for CodeLens-driven navigation to Collection View. |
| src/commands/playground/newPlayground.ts | Adds activationSource + context properties for playground creation and cross-feature starts. |
| src/commands/playground/executePlaygroundCode.ts | Adds code-block command classification + correlation to existing connection metadata. |
| src/commands/openInteractiveShell/openInteractiveShell.ts | Adds activationSource + viewId telemetry for shell open flows. |
| package.json | Adds .inline command contributions and updates inline menu wiring. |
| .github/skills/telemetry-instrumentation/SKILL.md | Expands telemetry instrumentation guidance (framework usage + common mistakes). |
| .github/copilot-instructions.md | Links the telemetry skill doc for repo guidance discoverability. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 26 out of 26 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
src/documentdb/playground/WorkerSessionManager.ts:385
terminateWorker()computesreasonbefore setting_terminatingIntentionally = true, soreasonwill almost always be reported as'forced'(including graceful shutdown). Consider passing an explicit reason intoterminateWorker()(e.g., fromshutdown()vskillWorker()), or set the reason after deciding which termination path is being used.
private terminateWorker(): void {
const wasAlive = !!this._worker;
const reason = this._terminatingIntentionally ? 'intentional' : 'forced';
if (this._worker) {
this._terminatingIntentionally = true;
void this._worker.terminate();
this._worker = undefined;
}
Unsanitized category strings from webview completionAccepted could inject arbitrary values into telemetry. Use z.enum() in tRPC and a Set-based allow-list in the command handler to restrict to known categories.
When commands are invoked via inline buttons, wrapper commands set activationSource to a specific value before calling the underlying command. Using ??= preserves that value instead of overwriting with 'treeNode'.
Two bugs fixed: 1. terminateWorker() computed reason before setting the _terminatingIntentionally flag, so intentional shutdowns logged as forced. Now the flag is set first. 2. handleWorkerExit() unconditionally emitted worker.unexpectedExit even for intentional terminations. Now guarded behind the flag check.
When Ctrl+C kills the worker during shell eval, the resulting Worker terminated error was recorded as Failed in telemetry. Now re-classified as Canceled via UserCancelledError. Also guards shell.sessionEnd behind a _sessionStarted flag so connection failures do not produce unpaired sessionEnd events without sessionStart.
…iew #5, #6)
- hasFilter now strips whitespace before comparing to {} to avoid
miscounting whitespace-padded empty filters.
- completionKindToCategory uses sortText prefix to distinguish JS global
constructors (4_) from BSON constructors (3_).
Covers all command categories (find, insert, update, delete, aggregate, count, index, help, show, use, exit, clear, cursor, other) and the classifyCodeBlock multi-statement analyzer.
The catch block swallowed errors, causing the telemetry framework to record result=Succeeded even on failure. Now re-throws after showing a minimal user message with a Show Details button that opens the output channel.
…w #10) sessionEvalCount is a numeric counter that needs aggregation (P50, avg, sum). Stored as a string property, dashboards must cast with todouble(). Now stored as a measurement for direct numeric aggregation.
Wraps ensureWorker() in its own callWithTelemetryAndErrorHandling so the framework auto-captures duration, result, and error for the connection phase independently. Keeps initDurationMs on playground.execute for convenience.
Telemetry Review — Deep Review Items ResolutionAddressing issues #8–#14 from the deep code review. Fixed#8 — #9 — #10 — #13 — Playground init/connect phase has no dedicated telemetry event (Medium) No Action (by design)#11 — #12 — Cross-feature navigation telemetry missing #14 — Completion acceptance not tracked for TS-provided method completions (Medium) |
…n and logging Co-authored-by: Copilot <copilot@github.com>
…nCommand category
Adds telemetry instrumentation to the new features launching in 0.8.0 to help identify areas for improvement.
What's covered
connectionCorrelationIdlinks shell/playground events to existingconnect.*metadata for dashboard joinsKey design decisions
shell.evalwraps the evaluate call in a singlecallWithTelemetryAndErrorHandling— the framework captures duration, result, and errors automatically.inlinevariants) inpackage.jsonclassifyCommand.ts) — no user data captured, only operation categoriesNew files
src/utils/classifyCommand.ts