Class: FastExists::Instrumentation::OpenTelemetry

Inherits:
Object
  • Object
show all
Defined in:
lib/fast_exists/instrumentation/open_telemetry.rb

Class Method Summary collapse

Class Method Details

.trace(name, attributes = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/fast_exists/instrumentation/open_telemetry.rb', line 6

def self.trace(name, attributes = {})
  if defined?(::OpenTelemetry::Trace)
    tracer = ::OpenTelemetry.tracer_provider.tracer("fast_exists", FastExists::VERSION)
    tracer.in_span("fast_exists.#{name}", attributes: attributes) do |span|
      yield span if block_given?
    end
  elsif block_given?
    yield nil
  end
end