Class: OpenTelemetry::Internal::ProxyInstrument Private
- Inherits:
-
Object
- Object
- OpenTelemetry::Internal::ProxyInstrument
- 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
-
#add(amount, attributes: nil) ⇒ Object
private
Delegates to the upgraded instrument's #add, if any.
-
#initialize(kind, name, unit, desc, callback, exemplar_filter, exemplar_reservoir) ⇒ ProxyInstrument
constructor
private
A new instance of ProxyInstrument.
-
#record(amount, attributes: nil) ⇒ Object
private
Delegates to the upgraded instrument's #record, if any.
-
#upgrade_with(meter) ⇒ Object
private
Replaces the no-op delegate with a real instrument from the given meter.
Constructor Details
#initialize(kind, name, unit, desc, callback, exemplar_filter, exemplar_reservoir) ⇒ 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 19 20 |
# File 'lib/opentelemetry/internal/proxy_instrument.rb', line 11 def initialize(kind, name, unit, desc, callback, exemplar_filter, exemplar_reservoir) @kind = kind @name = name @unit = unit @desc = desc @callback = callback @exemplar_filter = exemplar_filter @exemplar_reservoir = exemplar_reservoir @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.
Delegates to the upgraded instrument's #add, if any.
33 34 35 |
# File 'lib/opentelemetry/internal/proxy_instrument.rb', line 33 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.
Delegates to the upgraded instrument's #record, if any.
38 39 40 |
# File 'lib/opentelemetry/internal/proxy_instrument.rb', line 38 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.
Replaces the no-op delegate with a real instrument from the given meter.
23 24 25 26 27 28 29 30 |
# File 'lib/opentelemetry/internal/proxy_instrument.rb', line 23 def upgrade_with(meter) @delegate = case @kind when :counter, :histogram, :up_down_counter meter.send("create_#{@kind}", @name, unit: @unit, description: @desc, exemplar_filter: @exemplar_filter, exemplar_reservoir: @exemplar_reservoir) when :observable_counter, :observable_gauge, :observable_up_down_counter meter.send("create_#{@kind}", @name, unit: @unit, description: @desc, exemplar_filter: @exemplar_filter, exemplar_reservoir: @exemplar_reservoir, callback: @callback) end end |