Repository navigation
Conversation
Track patches and deferred imports so disabling MCP stops tracing and re-enabling restores one layer with the current tracer. Preserve copied callables and wrappers installed by other code. Closes traceloop#4653
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #4653.
After
McpInstrumentor().uninstrument(), completed MCP calls continued exporting spans. Re-enabling added another tracing layer even though each tool executed only once. The issue's in-memory reproducer now returns to the original tracing behavior:The two baseline tool spans are the legitimate client and server spans.
Changes
Scope is fully completed client sessions. Toggling instrumentation during an active session remains unsupported.
Validation
62 MCP package tests passed with FastMCP 2.12.2 and 2.14.3, using Python 3.11, MCP 1.26.0, OpenTelemetry SDK 1.42.1, and instrumentation 0.63b1.
The trimmed regressions still fail against the original production code and detect temporarily reintroduced lifecycle/retargeting defects.
Ruff, whitespace checks, and wheel build passed. The wheel includes the new helper.
Original issue reproducer passed; tool execution count and result remain unchanged.
I have added tests that cover my changes.
If adding a new instrumentation or changing an existing one, I've added screenshots from some observability platform showing the change.
PR name follows conventional commits format:
feat(instrumentation): ...orfix(instrumentation): ....(If applicable) I have updated the documentation accordingly.
Summary by CodeRabbit