Repository navigation
RUBY-3952 Cache tracing values that do not change - #3126
Merged
comandeo-mongo merged 2 commits intoNov 4, 2026
Merged
Conversation
The tracers rebuilt the same values on every operation and command: the connection attributes, the lsid string, the operation name and the transaction key. Build each once and reuse it, as the OpenTelemetry spec's performance guidelines recommend: connection attributes per connection, lsid strings in a small bounded cache, operation names per class, and the transaction key per transaction. The caches that more than one thread can write are guarded by a mutex.
The tracer stored the connection attributes and the transaction key in instance variables of Connection and Session that those classes did not declare, through instance_variable_get and _set. Declare them as private accessors on the classes that own the state, so they are visible where the objects are defined.
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.
The tracers rebuilt the same values for every operation and command: connection attributes, the lsid string, operation names and the transaction key. This builds each once and reuses it, as the OpenTelemetry spec's guidelines in mongodb/specifications#1986 suggest. The caches that more than one thread can write are guarded by a mutex, and the lsid cache is bounded. Recorded spans look the same as before. Follows #3124.
Jira: https://jira.mongodb.org/browse/RUBY-3952