Repository navigation
RUBY-3952 Reduce OpenTelemetry tracing overhead - #3122
Closed
comandeo-mongo wants to merge 11 commits into
Closed
comandeo-mongo wants to merge 11 commits into
comandeo-mongo wants to merge 11 commits into
Conversation
The command span read db.mongodb.server_connection_id from the server description, which comes from the monitoring connection's hello, not from the connection the command ran on. Since connection attributes are now cached per connection, that wrong value was also frozen for the connection's lifetime. Use the connection's own description, as command monitoring already does.
The OpenTelemetry spec's performance guidelines now say that a span that is not recording is still made current but gets no outcome, and that a span with an invalid context gets no work at all. Error attributes, exceptions, the error status and the reply's cursor id were still recorded on non-recording spans, and invalid spans were still finished because the early return ran inside the method's rescue and ensure. Move the span work into a helper so that an invalid context returns before it, and gate the outcome on recording?.
CommandTracer includes Secure, which now defines the same HELLO_COMMANDS. process_cursor_context defaulted its recording flag to true, so a caller that left it out would record attributes on a span that is not recording.
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.
Tracing cost up to 26% of throughput on small-document tasks, mostly from building span attributes before the driver knew whether the span would be recorded. This follows the guidelines in mongodb/specifications#1986: spans start with a small set of cheap attributes, spans with an invalid context get no work at all, and spans that aren't recording get no more attributes and no outcome. Values that don't change are cached. The benchmark from #3121 measures the result.
Recorded spans now take db.mongodb.server_connection_id from the command's own connection instead of the monitoring connection. db.operation.summary stays in the operation span's creation set because in Ruby it is the span name, which is built anyway.
Jira: https://jira.mongodb.org/browse/RUBY-3952