Class: Couchbase::OpenTelemetry::RequestTracer
- Inherits:
-
Tracing::RequestTracer
- Object
- Tracing::RequestTracer
- Couchbase::OpenTelemetry::RequestTracer
- Defined in:
- lib/couchbase/opentelemetry/request_tracer.rb
Instance Method Summary collapse
-
#initialize(tracer_provider) ⇒ RequestTracer
constructor
Initializes a Couchbase OpenTelemetry Request Tracer.
- #request_span(name, parent: nil, start_timestamp: nil) ⇒ Object
Constructor Details
#initialize(tracer_provider) ⇒ RequestTracer
Initializes a Couchbase OpenTelemetry Request Tracer
55 56 57 58 59 60 61 62 |
# File 'lib/couchbase/opentelemetry/request_tracer.rb', line 55 def initialize(tracer_provider) super() begin @wrapped = tracer_provider.tracer("com.couchbase.client/ruby") rescue StandardError => e raise Error::TracerError.new("Failed to create OpenTelemetry tracer: #{e.}", nil, e) end end |
Instance Method Details
#request_span(name, parent: nil, start_timestamp: nil) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/couchbase/opentelemetry/request_tracer.rb', line 64 def request_span(name, parent: nil, start_timestamp: nil) parent_context = parent.nil? ? nil : ::OpenTelemetry::Trace.context_with_span(parent.instance_variable_get(:@wrapped)) RequestSpan.new( @wrapped.start_span( name, with_parent: parent_context, start_timestamp: , kind: :client, ), ) rescue StandardError => e raise Error::TracerError.new("Failed to create OpenTelemetry span: #{e.}", nil, e) end |