Class: OpenTelemetry::Metrics::Meter

Inherits:
Object
  • Object
show all
Defined in:
lib/opentelemetry/metrics/meter.rb

Overview

No-op implementation of Meter.

Direct Known Subclasses

Internal::ProxyMeter

Constant Summary collapse

NAME_REGEX =
/\A[a-zA-Z][-.\w]{0,62}\z/
DuplicateInstrumentError =
Class.new(OpenTelemetry::Error)
InstrumentNameError =
Class.new(OpenTelemetry::Error)
InstrumentUnitError =
Class.new(OpenTelemetry::Error)
InstrumentDescriptionError =
Class.new(OpenTelemetry::Error)

Instance Method Summary collapse

Constructor Details

#initializeMeter

Returns a new instance of Meter.



27
28
29
30
# File 'lib/opentelemetry/metrics/meter.rb', line 27

def initialize
  @mutex = Mutex.new
  @instrument_registry = {}
end

Instance Method Details

#create_counter(name, unit: nil, description: nil) ⇒ Object



32
33
34
# File 'lib/opentelemetry/metrics/meter.rb', line 32

def create_counter(name, unit: nil, description: nil)
  create_instrument(:counter, name, unit, description, nil) { COUNTER }
end

#create_histogram(name, unit: nil, description: nil) ⇒ Object



36
37
38
# File 'lib/opentelemetry/metrics/meter.rb', line 36

def create_histogram(name, unit: nil, description: nil)
  create_instrument(:histogram, name, unit, description, nil) { HISTOGRAM }
end

#create_observable_counter(name, callback:, unit: nil, description: nil) ⇒ Object



44
45
46
# File 'lib/opentelemetry/metrics/meter.rb', line 44

def create_observable_counter(name, callback:, unit: nil, description: nil)
  create_instrument(:observable_counter, name, unit, description, callback) { OBSERVABLE_COUNTER }
end

#create_observable_gauge(name, callback:, unit: nil, description: nil) ⇒ Object



48
49
50
# File 'lib/opentelemetry/metrics/meter.rb', line 48

def create_observable_gauge(name, callback:, unit: nil, description: nil)
  create_instrument(:observable_gauge, name, unit, description, callback) { OBSERVABLE_GAUGE }
end

#create_observable_up_down_counter(name, callback:, unit: nil, description: nil) ⇒ Object



52
53
54
# File 'lib/opentelemetry/metrics/meter.rb', line 52

def create_observable_up_down_counter(name, callback:, unit: nil, description: nil)
  create_instrument(:observable_up_down_counter, name, unit, description, callback) { OBSERVABLE_UP_DOWN_COUNTER }
end

#create_up_down_counter(name, unit: nil, description: nil) ⇒ Object



40
41
42
# File 'lib/opentelemetry/metrics/meter.rb', line 40

def create_up_down_counter(name, unit: nil, description: nil)
  create_instrument(:up_down_counter, name, unit, description, nil) { UP_DOWN_COUNTER }
end