Repository navigation
Conversation
atesgoral
force-pushed
the
fix/instrumentation-data-per-request
branch
2 times, most recently
from
November 6, 2026 07:14
d323aa7 to
43614b4
Compare
atesgoral
marked this pull request as ready for review
November 6, 2026 07:18
atesgoral
marked this pull request as draft
November 6, 2026 07:54
atesgoral
force-pushed
the
fix/instrumentation-data-per-request
branch
from
November 6, 2026 13:58
43614b4 to
2121369
Compare
atesgoral
marked this pull request as ready for review
November 6, 2026 14:14
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.
Motivation and Context
Concurrent requests overwrote each other's instrumentation data, because
instrument_callkept one record on the shared host. The record is now built insideinstrument_calland passed explicitly through the SDK's request handlers. Each writer updates that record, and both hooks receive the same hash for the request. There is no ambient request context.add_instrumentation_data(**kwargs)stays as a soft-deprecated compatibility shim with its existing behavior. It still uses a shared record and is not safe for concurrent application calls. Both hook signatures are unchanged.Fixes #657.
How Has This Been Tested?
test/mcp/instrumentation_test.rbandtest/mcp/server_test.rbcover overlapping requests, distinct clients and arguments, late errors, nested calls, callback failures and hook identity.The five isolation regressions use APIs that already exist on
main. Against its production code, all five fail with duplicate method or tool records, with no errors. The compatibility test passes there. Against the current published head, all six cases pass (61 assertions). The compatibility test includes updates after a request returns.The focused tests pass (304 runs, 901 assertions), and so does the full suite (2,506 runs, 8,325 assertions). RuboCop is clean on the changed files.
Breaking Changes
None. Both hook signatures and
add_instrumentation_data(**kwargs)keep their behavior, and the helper is now marked@deprecated. Theinstrument_callblock also receives the record as an argument, which blocks that ignore it do not notice.Types of changes
Checklist
Additional context
The diff touches the private handler signatures, since passing the record explicitly replaces the implicit context. I found no smaller change that is correct without ambient state, because the old helper has no request identity to select a record.