Class: Mongo::Tracing::OpenTelemetry::OperationTracer Private
- Inherits:
-
Object
- Object
- Mongo::Tracing::OpenTelemetry::OperationTracer
- Extended by:
- Forwardable
- Defined in:
- lib/mongo/tracing/open_telemetry/operation_tracer.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
OperationTracer is responsible for tracing MongoDB driver operations using OpenTelemetry.
Instance Method Summary collapse
-
#initialize(otel_tracer, parent_tracer) ⇒ OperationTracer
constructor
private
Initializes a new OperationTracer.
-
#trace_operation(operation, operation_context, op_name: nil) { ... } ⇒ Object
private
Trace a MongoDB operation.
Constructor Details
#initialize(otel_tracer, parent_tracer) ⇒ OperationTracer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initializes a new OperationTracer.
37 38 39 40 |
# File 'lib/mongo/tracing/open_telemetry/operation_tracer.rb', line 37 def initialize(otel_tracer, parent_tracer) @otel_tracer = otel_tracer @parent_tracer = parent_tracer end |
Instance Method Details
#trace_operation(operation, operation_context, op_name: nil) { ... } ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Trace a MongoDB operation.
Creates an OpenTelemetry span for the operation, capturing attributes such as database name, collection name, operation name, and cursor ID. The span is finished automatically when the operation completes or fails.
rubocop:disable Lint/RescueException
58 59 60 61 62 63 64 65 66 |
# File 'lib/mongo/tracing/open_telemetry/operation_tracer.rb', line 58 def trace_operation(operation, operation_context, op_name: nil, &block) span = create_operation_span(operation, operation_context, op_name) execute_with_span(span, operation, &block) rescue Exception => e handle_span_exception(span, e) raise e ensure span&.finish end |