Repository navigation
Conversation
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.
Summary
FastMCPInstrumentorstores a single_server_namefor the whole instrumentor and overwrites it every time aFastMCPserver is constructed. A process that hosts more than one server therefore labels the spans of every server with the name of the last one constructed. An unnamed server also inherits the previous server's name instead of the generated name FastMCP gave it.The name is now resolved from the server object after
__init__finishes (instance.name, which covers positional, keyword, and generated names) and kept per server in aWeakKeyDictionarykeyed by that server's tool manager, which is the object the tool-call wrapper receives.Reproduction: create
FastMCP("first-server")with a tool, then constructFastMCP("second-server"), then call the first server's tool. On the base commit the server-side spans carrytraceloop.workflow.name=second-server.mcp; with the change they carryfirst-server.mcp. The second test covers an unnamed server, whose generated name was previously replaced by the last named server.Tests
Added
tests/test_fastmcp_server_names.py:Both fail on the base commit with the wrong
traceloop.workflow.namevalue and pass with the change.Validation in the package's locked environment (
uv sync --frozen --all-groups, Python 3.12):pytest tests-> 51 passed.ruff checkon both changed files -> clean.Checklist
feat(instrumentation): ...orfix(instrumentation): ....The change is visible in span attributes, which the tests assert with an in-memory exporter; no hosted platform is involved.
Summary by CodeRabbit