You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: plans/cli_mcp_telemetry_instrumentation_plan.md
+27-13Lines changed: 27 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -304,19 +304,17 @@ Not in scope for this CLI PR, but documents the expected server-side changes:
304
304
305
305
## File Change Summary
306
306
307
-
| File | Change | Complexity |
308
-
|------|--------|-----------|
309
-
|`pkg/hookdeck/telemetry.go`| Add fields, invocation ID generator | Small |
310
-
|`pkg/hookdeck/telemetry_test.go`| Update tests for new fields | Small |
311
-
|`pkg/hookdeck/client.go`| Add `Telemetry` field, `WithTelemetry()`, update `PerformRequest`| Small |
312
-
|`pkg/cmd/root.go`| Add `PersistentPreRun` with `initTelemetry()`| Small |
313
-
|`pkg/cmd/connection.go`| Call `initTelemetry()` in existing `PersistentPreRun`| Trivial |
314
-
|`pkg/gateway/mcp/server.go`| Capture MCP client info, store on Server struct | Small |
315
-
|`pkg/gateway/mcp/tools.go`| Add telemetry wrapping in tool dispatch | Medium |
316
-
|`pkg/hookdeck/sdkclient.go`| No changes needed (already reads singleton) | None |
317
-
|`pkg/config/config.go`| Add `TelemetryDisabled` field, read from viper in `constructConfig()`| Small |
318
-
|`pkg/hookdeck/telemetry.go`| Update `telemetryOptedOut()` to accept config flag; add `DetectEnvironment()` for CI detection; add `Environment` field | Small |
319
-
|`pkg/hookdeck/client.go`| Add `TelemetryDisabled` field, thread through opt-out check | Small |
307
+
| File | Change | Phase | Complexity |
308
+
|------|--------|-------|-----------|
309
+
|`pkg/hookdeck/telemetry.go`| Add `Source`, `Environment`, `InvocationID` fields; `NewInvocationID()` generator; `DetectEnvironment()` for CI; update `telemetryOptedOut()` to accept config flag | 1, 5 | Small |
310
+
|`pkg/hookdeck/telemetry_test.go`| Update tests for new fields, opt-out with config flag, environment detection | 1, 5 | Small |
311
+
|`pkg/hookdeck/client.go`| Add `Telemetry` field + `TelemetryDisabled` field; `WithTelemetry()` clone method; update `PerformRequest` to use per-request telemetry override and config-based opt-out | 2, 5 | Small |
312
+
|`pkg/cmd/root.go`| Add `PersistentPreRun` with `initTelemetry()` helper | 1 | Small |
313
+
|`pkg/cmd/connection.go`| Call `initTelemetry()` in existing `PersistentPreRun`| 1 | Trivial |
314
+
|`pkg/gateway/mcp/server.go`| Capture MCP client info, store on Server struct | 2 | Small |
315
+
|`pkg/gateway/mcp/tools.go`| Add telemetry wrapping in tool dispatch (central `WithTelemetry` per tool call) | 2 | Medium |
316
+
|`pkg/hookdeck/sdkclient.go`| Add `TelemetryDisabled` field, thread through opt-out check | 5 | Small |
317
+
|`pkg/config/config.go`| Add `TelemetryDisabled` field, read from viper in `constructConfig()`| 5 | Small |
This integrates cleanly with Phase 1's telemetry struct as a new `environment` field. Server-side, PostHog dashboards get two clean dimensions to slice by.
457
455
456
+
## Key Source Files
457
+
458
+
These are the files an implementer needs to read before starting:
459
+
460
+
| File | What it contains |
461
+
|------|-----------------|
462
+
|`pkg/hookdeck/telemetry.go`|`CLITelemetry` struct, singleton `GetTelemetryInstance()`, `getTelemetryHeader()`, `telemetryOptedOut()` — all telemetry logic lives here |
463
+
|`pkg/hookdeck/client.go`| Internal HTTP client, `PerformRequest()` where telemetry header is set per-request (line ~107) |
464
+
|`pkg/hookdeck/sdkclient.go`|`CreateSDKClient()` where telemetry header is baked in at construction (line ~39) |
465
+
|`pkg/config/config.go`|`Config` struct, `InitConfig()`, `constructConfig()` with viper precedence chain, `getConfigPath()` for local/global config resolution |
466
+
|`pkg/config/profile.go`|`Profile` struct, save/load/remove profile, field getter helpers |
467
+
|`pkg/cmd/root.go`| Root cobra command, `cobra.OnInitialize` wiring, where `PersistentPreRun` should be added |
468
+
|`pkg/cmd/connection.go`| Has its own `PersistentPreRun` (deprecation warning) — must be updated to call shared `initTelemetry()`|
469
+
|`pkg/gateway/mcp/server.go`| MCP server setup, `Server.Run()`, session management |
0 commit comments