Skip to content

Conversation

@nirinchev
Copy link
Collaborator

Proposed changes

Reworks telemetry events a bit - now we can provide arbitrary kvp data from resolveTelemetryMetadata in tools. This allows us to include the operations as additional field in properties. Additionally, renamed the fixed fields in TelemetryToolMetadata to match the names we're sending so we can just spread the object instead of the custom handling we had previously.

@nirinchev nirinchev requested a review from a team as a code owner October 29, 2025 13:21
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors telemetry event handling to allow tools to include arbitrary key-value pairs in telemetry metadata, and disables telemetry in accuracy tests. The refactoring renames metadata fields to match the actual property names being sent (e.g., projectIdproject_id), enabling direct spreading of metadata objects instead of manual property mapping.

Key changes:

  • Extended TelemetryToolMetadata type to support arbitrary string/number/array properties via intersection type
  • Renamed fixed telemetry metadata fields to match transmitted property names (projectIdproject_id, etc.)
  • Modified resolveTelemetryMetadata to accept result and args parameters for context-aware metadata
  • Disabled telemetry in accuracy tests via DO_NOT_TRACK=1 environment variable

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/tools/tool.ts Extended TelemetryToolMetadata type and simplified event emission by spreading metadata directly instead of manual property assignment
src/tools/atlas/atlasTool.ts Updated field names from projectId/orgId to project_id/org_id to match new naming convention
src/tools/mongodb/mongodbTool.ts Updated projectId to project_id in metadata assignment
src/tools/atlasLocal/atlasLocalTool.ts Updated atlasLocaldeploymentId to atlas_local_deployment_id in metadata assignment
src/tools/atlas/read/getPerformanceAdvisor.ts Implemented resolveTelemetryMetadata override to include operations array in telemetry events
src/telemetry/types.ts Extended TelemetryEvent properties with index signature to support arbitrary metadata fields
tests/unit/toolBase.test.ts Added comprehensive tests for resolveTelemetryMetadata functionality with mock telemetry emission verification
tests/integration/tools/atlas/performanceAdvisor.test.ts Added telemetry emission tests for operations metadata and reorganized test structure with proper mock setup
tests/integration/elicitation.test.ts Removed redundant telemetry disable configuration (now handled globally)
tests/accuracy/sdk/accuracyTestingClient.ts Disabled telemetry in accuracy tests using DO_NOT_TRACK environment variable
component: "tool",
duration_ms: duration,
result: result.isError ? "failure" : "success",
...metadata,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice thanks!

@nirinchev nirinchev force-pushed the ni/perf-advisor-telemetry branch from e8d664d to 2271809 Compare October 29, 2025 13:26
@coveralls
Copy link
Collaborator

coveralls commented Oct 29, 2025

Pull Request Test Coverage Report for Build 19066434028

Details

  • 4 of 22 (18.18%) changed or added relevant lines in 5 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.1%) to 80.059%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/tools/atlasLocal/atlasLocalTool.ts 1 3 33.33%
src/tools/mongodb/mongodbTool.ts 0 3 0.0%
src/tools/atlas/atlasTool.ts 1 5 20.0%
src/tools/atlas/read/getPerformanceAdvisor.ts 1 10 10.0%
Totals Coverage Status
Change from base Build 19030362681: 0.1%
Covered Lines: 6489
Relevant Lines: 7991

💛 - Coveralls
@nirinchev nirinchev changed the title chore: disable telemetry in accuracy tests MCP-277 chore: include tool args for perf advisor telemetry MCP-277 Oct 29, 2025
@blva
Copy link
Collaborator

blva commented Oct 29, 2025

note: let's make sure to trigger the perf advisor tests here via GH actions

extra: RequestHandlerExtra<ServerRequest, ServerNotification>
): TelemetryToolMetadata {
const baseMetadata = super.resolveTelemetryMetadata(result, args, extra);
baseMetadata.operations = args.operations;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[q] why not capture this new field in TelemetryToolMetadata? keeping track of the data we populate there is handy - makes it easy to get a list of properties in the long term

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fair - I think it's a bit annoying if it becomes unwieldy as we add more and more stuff. But you're right that by being overly permissive, we lose oversight into what's being sent to telemetry. I'll try to find a better solution.

Copy link
Collaborator

@kylelai1 kylelai1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!! No specific qualms on the perf advisor tool or testing from me.

@nirinchev nirinchev requested a review from blva November 4, 2025 11:00
Copy link
Collaborator

@blva blva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks for the changes

@nirinchev nirinchev merged commit 4d56757 into main Nov 4, 2025
19 checks passed
@nirinchev nirinchev deleted the ni/perf-advisor-telemetry branch November 4, 2025 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

5 participants