Feat/privacy safe telemetry - #700
Conversation
Code Review by Qodo
1.
|
📝 WalkthroughWalkthroughThis PR introduces privacy-safe MCP telemetry with bounded tool taxonomy, sanitized arguments and results, session lifecycle metrics, retry observations, Sentry filtering, telemetry flushing, and dashboard/data-dictionary documentation. ChangesPrivacy-safe telemetry
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant MCPClient
participant ToolRuntime
participant TelemetryWrapper
participant Metrics
participant Sentry
MCPClient->>ToolRuntime: invoke typed tool
ToolRuntime->>TelemetryWrapper: pass taxonomy metadata
TelemetryWrapper->>Metrics: record bounded outcome and duration
TelemetryWrapper->>Sentry: submit sanitized span
Possibly related issues
Possibly related PRs
Suggested labels: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
MCP tool token costMeasured with
Change from baseline
Per-tool changes
Per-tool breakdown
Per-tool counts encode each complete tool object independently. The total encodes the complete |
PR Summary by QodoPrivacy-safe MCP telemetry: bounded taxonomy, outcomes, sessions, and dashboards
AI Description
Diagram
High-Level Assessment
Files changed (42)
|
PR Summary by QodoAdd privacy-safe MCP telemetry taxonomy, outcomes, and session metrics
AI Description
Diagram
High-Level Assessment
Files changed (42)
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #700 +/- ##
==========================================
- Coverage 95.45% 94.52% -0.93%
==========================================
Files 47 50 +3
Lines 2090 2266 +176
Branches 575 639 +64
==========================================
+ Hits 1995 2142 +147
- Misses 32 51 +19
- Partials 63 73 +10 ☔ View full report in Codecov by Harness. |
Unit Test Results 1 files 50 suites 4s ⏱️ Results for commit ab81cae. ♻️ This comment has been updated with latest results. |
There was a problem hiding this comment.
✨ PR Review
The PR introduces a comprehensive privacy-safe telemetry taxonomy with bounded tool outcomes, session lifecycle signals, and sanitized Sentry spans. The implementation is well-structured, but there is one concrete functional gap: the kind field required by ToolTelemetryMetadata is never populated in any tool definition, which breaks the taxonomy test added in the same PR.
1 issues detected:
🐞 Bug - `kind` is a required field in `ToolTelemetryMetadata` but is absent from every tool definition, causing the taxonomy test to fail and emitting `undefined` as a bounded metric dimension. 🛠️
Details: Every tool definition in this PR adds feature and operation fields but omits the kind field required by ToolTelemetryMetadata. The register.test.ts taxonomy test added in the same PR asserts expect(["read", "write"]).toContain(definition.kind) for every tool definition, which will fail for all tools because definition.kind is undefined. The taxonomyAttributes function in telemetry-wrapper.ts will emit "mcp.tool.kind": undefined, sending the literal string "undefined" as a span attribute instead of a bounded taxonomy value.
File: src/tools/workouts.ts (61-63)
🛠️ A suggested code correction is included in the review comments.
Generated by LinearB AI and added by gitStream.
AI-generated content may contain inaccuracies. Please verify before using.
💡 Tip: You can customize your AI Review using Guidelines Learn how
|
Tick the box to add this pull request to the merge queue (same as
|
There was a problem hiding this comment.
Code Review
This pull request introduces a privacy-safe MCP telemetry taxonomy, bounded tool outcomes, session compatibility signals, and dashboard guidance. It refactors the telemetry and observability wrappers to capture only structural argument presence, bucketed counts, and safe result-shape metadata rather than raw arguments or result bodies. The review feedback highlights critical TypeScript compilation and contravariance type errors introduced by narrowing the parameter types of withErrorHandling, withObservability, withTelemetry, and ToolHandlerWrapper away from the generic Record<string, unknown> expected by the MCP SDK. Additionally, an issue was identified in the graceful shutdown watchdog timer where a timeout could cause a delayed exit and report an incorrect successful exit code instead of a hard failure.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Code Review by Qodo
Context used✅ Compliance rules (platform):
65 rules 1.
|
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/telemetry-dashboards.md`:
- Line 31: Update the Thrown-error rate metric around mcp.tool.errors so
error_type is either replaced with an approved bounded field or formally defined
as a finite, sanitized tool-error taxonomy in the data dictionary and
corresponding instrumentation. Keep the dashboard grouping and implementation
aligned with the chosen documented contract.
In `@docs/telemetry-data-dictionary.md`:
- Around line 29-30: Keep exact tool names debugging-only by updating
docs/telemetry-data-dictionary.md lines 29-30 to define the permitted
short-lived lifetime and access policy. In docs/telemetry-dashboards.md lines
14-15 and 30-32, remove tool_name from product-adoption and reliability
groupings, or replace it with approved bounded taxonomy fields; do not retain it
in dashboards unless they are explicitly short-lived and access-controlled.
In `@src/utils/mcp-session-observability.ts`:
- Around line 46-57: Update normalizeMetadata and SAFE_METADATA_PATTERN so
client-reported metadata cannot pass arbitrary free-text values such as “private
client metadata”; tighten the accepted character set, including disallowing
spaces, while preserving the existing missing, empty, oversized, and
unsafe-value fallback to UNKNOWN_METADATA.
In `@src/utils/telemetry-wrapper.ts`:
- Around line 92-116: Update setWorkflowAttributes to safely handle missing or
undefined workflow.pagination before iterating, and isolate any telemetry
attribute-setting failures so they cannot escape withTelemetry’s try block.
Preserve the successful tool result and avoid converting instrumentation errors
into thrown tool-call failures.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 7bff7176-cc8e-4fcc-b6b3-3879e9b199cb
📒 Files selected for processing (42)
.changeset/privacy-safe-telemetry.mddocs/telemetry-dashboards.mddocs/telemetry-data-dictionary.mdsrc/cli.tssrc/index.test.tssrc/index.tssrc/shared-server.tssrc/tools/body-measurements.tssrc/tools/define-tool.tssrc/tools/folders.tssrc/tools/register.test.tssrc/tools/register.tssrc/tools/routine-discovery.tssrc/tools/routines.tssrc/tools/templates.tssrc/tools/tool-runtime.tssrc/tools/user.tssrc/tools/workflows.tssrc/tools/workouts.tssrc/utils/error-handler.tssrc/utils/graceful-shutdown.test.tssrc/utils/graceful-shutdown.tssrc/utils/hevy-client-observability.test.tssrc/utils/hevy-client-observability.tssrc/utils/hevyClientKubb.test.tssrc/utils/hevyClientKubb.tssrc/utils/mcp-session-observability.test.tssrc/utils/mcp-session-observability.tssrc/utils/metrics.tssrc/utils/observability-wrapper.test.tssrc/utils/observability-wrapper.tssrc/utils/response-formatter.test.tssrc/utils/response-formatter.tssrc/utils/result-telemetry.tssrc/utils/sentry-privacy.tssrc/utils/stdio-observability.test.tssrc/utils/stdio-observability.tssrc/utils/telemetry-wrapper.test.tssrc/utils/telemetry-wrapper.tssrc/utils/telemetry.test.tssrc/utils/telemetry.tssrc/utils/tool-taxonomy.ts
Co-Authored-By: Oz <oz-agent@warp.dev>
Bundle ReportChanges will increase total bundle size by 14.35kB (9.09%) ⬆️
Affected Assets, Files, and Routes:view changes for bundle: hevy-mcp-esmAssets Changed:
Files in
Files in
|
Add privacy-safe MCP telemetry taxonomy, bounded tool outcomes, session compatibility signals, and dashboard guidance.
Primary changes
Reviewer walkthrough
src/utils/tool-taxonomy.ts,src/utils/telemetry-wrapper.ts, andsrc/utils/response-formatter.tsfor taxonomy, bounded arguments/results, and outcome instrumentation.src/utils/mcp-session-observability.ts,src/utils/stdio-observability.ts,src/index.ts, andsrc/utils/graceful-shutdown.ts.docs/telemetry-data-dictionary.mdanddocs/telemetry-dashboards.mdalongside the focused tests.Correctness and invariants
Testing and QA
docs/telemetry-dashboards.md.✨ PR Description
Purpose: Implement privacy-safe telemetry system with bounded taxonomy, result metrics, and sanitized client metadata to ensure no sensitive data exposure.
Main changes:
Generated by LinearB AI and added by gitStream.
AI-generated content may contain inaccuracies. Please verify before using.
💡 Tip: You can customize your AI Description using Guidelines Learn how
Summary by CodeRabbit
Refs #697
Refs #694
Refs #696
Refs #698