Class: Observable::Instrumenter

Inherits:
Object
  • Object
show all
Defined in:
lib/observable/instrumenter.rb

Defined Under Namespace

Classes: ArgumentExtractor, CallerInformation, InstrumentationError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tracer: nil, config: nil) ⇒ Instrumenter

Returns a new instance of Instrumenter.



8
9
10
11
# File 'lib/observable/instrumenter.rb', line 8

def initialize(tracer: nil, config: nil)
  @config = config || Configuration.config
  @tracer = tracer || OpenTelemetry.tracer_provider.tracer(@config.tracer_name)
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



6
7
8
# File 'lib/observable/instrumenter.rb', line 6

def config
  @config
end

#last_captured_namespaceObject (readonly)

Returns the value of attribute last_captured_namespace.



6
7
8
# File 'lib/observable/instrumenter.rb', line 6

def last_captured_namespace
  @last_captured_namespace
end

Instance Method Details

#instrument(caller_binding = nil, &block) ⇒ Object



13
14
15
16
17
# File 'lib/observable/instrumenter.rb', line 13

def instrument(caller_binding = nil, &block)
  @caller_binding = caller_binding
  caller_info = extract_caller_information
  create_instrumented_span(caller_info, &block)
end