-
Couldn't load subscription status.
- Fork 149
chore: include tool args for perf advisor telemetry MCP-277 #706
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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., projectId → project_id), enabling direct spreading of metadata objects instead of manual property mapping.
Key changes:
- Extended
TelemetryToolMetadatatype to support arbitrary string/number/array properties via intersection type - Renamed fixed telemetry metadata fields to match transmitted property names (
projectId→project_id, etc.) - Modified
resolveTelemetryMetadatato acceptresultandargsparameters for context-aware metadata - Disabled telemetry in accuracy tests via
DO_NOT_TRACK=1environment 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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice thanks!
e8d664d to
2271809
Compare
Pull Request Test Coverage Report for Build 18910629949Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
|
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; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
Proposed changes
Reworks telemetry events a bit - now we can provide arbitrary kvp data from
resolveTelemetryMetadatain tools. This allows us to include the operations as additional field in properties. Additionally, renamed the fixed fields inTelemetryToolMetadatato match the names we're sending so we can just spread the object instead of the custom handling we had previously.