-
Notifications
You must be signed in to change notification settings - Fork 534
RUBY-3612 OpenTelemetry #2957
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
RUBY-3612 OpenTelemetry #2957
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds OpenTelemetry tracing support to the MongoDB Ruby driver, enabling distributed tracing capabilities for MongoDB operations and commands following the OpenTelemetry semantic conventions for database instrumentation.
Key changes:
- New tracing infrastructure with
Mongo::Tracing::OpenTelemetry::Tracer,OperationTracer, andCommandTracerclasses - Integration of tracing into client, collection, database, and session operations
- Support for transaction span tracking and cursor context management
- Environment variable configuration for enabling tracing and query text capture
- Comprehensive test suite including unified spec tests for OpenTelemetry
Reviewed changes
Copilot reviewed 62 out of 62 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
lib/mongo/tracing.rb |
Main tracing module with factory method for creating tracers |
lib/mongo/tracing/open_telemetry/tracer.rb |
Core tracer implementation managing operation and command tracing |
lib/mongo/tracing/open_telemetry/operation_tracer.rb |
Tracer for driver-level operations with span attribute management |
lib/mongo/tracing/open_telemetry/command_tracer.rb |
Tracer for server commands with query text capture support |
lib/mongo/client.rb |
Client integration for tracer initialization and configuration |
lib/mongo/session.rb |
Transaction span lifecycle management |
lib/mongo/operation/shared/executable.rb |
Command tracing integration in operation execution |
lib/mongo/collection.rb |
Operation tracing for collection methods |
lib/mongo/collection/view/*.rb |
Tracing integration for view operations |
lib/mongo/index/view.rb |
Index operation tracing |
spec/support/tracing.rb |
Mock tracing infrastructure for testing |
spec/spec_tests/open_telemetry_spec.rb |
Unified spec test runner for OpenTelemetry |
spec/spec_tests/data/open_telemetry/**/*.yml |
Comprehensive test specifications |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| message = build_message(connection, context) | ||
| connection.tracer.trace_command(message, context, connection) do | ||
| result = result_class.new(*dispatch_message(message, connection, context, options), context: context, connection: connection) | ||
| yield result |
Copilot
AI
Dec 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method signature changed from yielding nothing to yielding the result. However, line 48 shows "get_result(connection, context, options) do |result|" which indicates a block is expected, but this is inconsistent with how the method is called elsewhere. The calling code needs to pass a block to handle the result.
| yield result | |
| if block_given? | |
| yield result | |
| else | |
| result | |
| end |
lib/mongo/tracing.rb
Outdated
| module Tracing | ||
| # Creates a new OpenTelemetry tracer for instrumenting MongoDB operations. | ||
| # | ||
| # @param enabled [Boolean, nil] Whether tracing is enabled. Defautl to nil, which |
Copilot
AI
Dec 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment has a typo: "Defautl" should be "Default".
| # @param enabled [Boolean, nil] Whether tracing is enabled. Defautl to nil, which | |
| # @param enabled [Boolean, nil] Whether tracing is enabled. Default to nil, which |
|
|
||
| # Whether OpenTelemetry is enabled or not. | ||
| # | ||
| # # @return [Boolean] true if OpenTelemetry is enabled, false otherwise. |
Copilot
AI
Dec 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment has an extra space in "# @return" and uses "Boolean | nil" which is unconventional for Ruby documentation. The standard format would be "Boolean, nil" or "[Boolean, nil]".
| # # @return [Boolean] true if OpenTelemetry is enabled, false otherwise. | |
| # @return [Boolean] true if OpenTelemetry is enabled, false otherwise. |
No description provided.