Class: OpenTelemetry::Internal::ProxyInstrument Private

Inherits:
Object
  • Object
show all
Defined in:
lib/opentelemetry/internal/proxy_instrument.rb

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.

Instance Method Summary collapse

Constructor Details

#initialize(kind, name, unit, desc, callable) ⇒ ProxyInstrument

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.

Returns a new instance of ProxyInstrument.



11
12
13
14
15
16
17
18
# File 'lib/opentelemetry/internal/proxy_instrument.rb', line 11

def initialize(kind, name, unit, desc, callable)
  @kind = kind
  @name = name
  @unit = unit
  @desc = desc
  @callable = callable
  @delegate = nil
end

Instance Method Details

#add(amount, attributes: 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.



29
30
31
# File 'lib/opentelemetry/internal/proxy_instrument.rb', line 29

def add(amount, attributes: nil)
  @delegate&.add(amount, attributes: attributes)
end

#record(amount, attributes: 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.



33
34
35
# File 'lib/opentelemetry/internal/proxy_instrument.rb', line 33

def record(amount, attributes: nil)
  @delegate&.record(amount, attributes: attributes)
end

#upgrade_with(meter) ⇒ 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.



20
21
22
23
24
25
26
27
# File 'lib/opentelemetry/internal/proxy_instrument.rb', line 20

def upgrade_with(meter)
  @delegate = case @kind
              when :counter, :histogram, :up_down_counter
                meter.send("create_#{@kind}", @name, unit: @unit, description: @desc)
              when :observable_counter, :observable_gauge, :observable_up_down_counter
                meter.send("create_#{@kind}", @name, unit: @unit, description: @desc, callback: @callback)
              end
end