Skip to content

Conversation

@comandeo
Copy link
Contributor

@comandeo comandeo commented Nov 3, 2025

No description provided.

@comandeo-mongo comandeo-mongo marked this pull request as ready for review December 12, 2025 08:54
@comandeo-mongo comandeo-mongo requested a review from a team as a code owner December 12, 2025 08:54
Copy link

Copilot AI left a 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, and CommandTracer classes
  • 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
Copy link

Copilot AI Dec 12, 2025

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.

Suggested change
yield result
if block_given?
yield result
else
result
end

Copilot uses AI. Check for mistakes.
module Tracing
# Creates a new OpenTelemetry tracer for instrumenting MongoDB operations.
#
# @param enabled [Boolean, nil] Whether tracing is enabled. Defautl to nil, which
Copy link

Copilot AI Dec 12, 2025

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".

Suggested change
# @param enabled [Boolean, nil] Whether tracing is enabled. Defautl to nil, which
# @param enabled [Boolean, nil] Whether tracing is enabled. Default to nil, which

Copilot uses AI. Check for mistakes.

# Whether OpenTelemetry is enabled or not.
#
# # @return [Boolean] true if OpenTelemetry is enabled, false otherwise.
Copy link

Copilot AI Dec 12, 2025

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]".

Suggested change
# # @return [Boolean] true if OpenTelemetry is enabled, false otherwise.
# @return [Boolean] true if OpenTelemetry is enabled, false otherwise.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants