Class: OpenTelemetry::Metrics::Meter
- Inherits:
-
Object
- Object
- OpenTelemetry::Metrics::Meter
- Defined in:
- lib/opentelemetry/metrics/meter.rb
Overview
No-op implementation of Meter.
Direct Known Subclasses
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
-
#create_counter(name, unit: nil, description: nil) ⇒ nil
Counter is a synchronous Instrument which supports non-negative increments.
-
#create_gauge(name, unit: nil, description: nil) ⇒ nil
Gauge is an synchronous Instrument which reports non-additive value(s).
-
#create_histogram(name, unit: nil, description: nil) ⇒ nil
Histogram is a synchronous Instrument which can be used to report arbitrary values that are likely to be statistically meaningful.
-
#create_observable_counter(name, callback:, unit: nil, description: nil) ⇒ nil
ObservableCounter is an asynchronous Instrument which reports monotonically increasing value(s) when the instrument is being observed.
-
#create_observable_gauge(name, callback:, unit: nil, description: nil) ⇒ nil
ObservableGauge is an asynchronous Instrument which reports non-additive value(s) (e.g. the room temperature - it makes no sense to report the temperature value from multiple rooms and sum them up) when the instrument is being observed.
-
#create_observable_up_down_counter(name, callback:, unit: nil, description: nil) ⇒ nil
ObservableUpDownCounter is an asynchronous Instrument which reports additive value(s) (e.g. the process heap size - it makes sense to report the heap size from multiple processes and sum them up, so we get the total heap usage) when the instrument is being observed.
-
#create_up_down_counter(name, unit: nil, description: nil) ⇒ nil
UpDownCounter is a synchronous Instrument which supports increments and decrements.
-
#initialize ⇒ Meter
constructor
A new instance of Meter.
Constructor Details
#initialize ⇒ Meter
Returns a new instance of Meter.
28 29 30 31 |
# File 'lib/opentelemetry/metrics/meter.rb', line 28 def initialize @mutex = Mutex.new @instrument_registry = {} end |
Instance Method Details
#create_counter(name, unit: nil, description: nil) ⇒ nil
Counter is a synchronous Instrument which supports non-negative increments.
With this api call:
exception_counter = meter.create_counter(“exceptions”, description: “number of exceptions caught”, unit: 's')
46 47 48 |
# File 'lib/opentelemetry/metrics/meter.rb', line 46 def create_counter(name, unit: nil, description: nil) create_instrument(:counter, name, unit, description, nil) { COUNTER } end |
#create_gauge(name, unit: nil, description: nil) ⇒ nil
Gauge is an synchronous Instrument which reports non-additive value(s)
With this api call:
meter.create_gauge(“cpu.frequency”, description: “the real-time CPU clock speed”, unit: “ms”)
83 84 85 |
# File 'lib/opentelemetry/metrics/meter.rb', line 83 def create_gauge(name, unit: nil, description: nil) create_instrument(:gauge, name, unit, description, nil) { GAUGE } end |
#create_histogram(name, unit: nil, description: nil) ⇒ nil
Histogram is a synchronous Instrument which can be used to report arbitrary values that are likely to be statistically meaningful. It is intended for statistics such as histograms, summaries, and percentiles.
With this api call:
http_server_duration = meter.create_histogram(“http.server.duration”, description: “measures the duration of the inbound HTTP request”, unit: “s”)
65 66 67 |
# File 'lib/opentelemetry/metrics/meter.rb', line 65 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) ⇒ nil
ObservableCounter is an asynchronous Instrument which reports monotonically increasing value(s) when the instrument is being observed.
With this api call:
pf_callback = -> { # collect metrics here } meter.create_observable_counter(“PF”, pf_callback, description: “process page faults”, unit: 'ms')
122 123 124 |
# File 'lib/opentelemetry/metrics/meter.rb', line 122 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) ⇒ nil
ObservableGauge is an asynchronous Instrument which reports non-additive value(s) (e.g. the room temperature - it makes no sense to report the temperature value from multiple rooms and sum them up) when the instrument is being observed.
With this api call:
pf_callback = -> { # collect metrics here } meter.create_observable_counter(“cpu.frequency”, pf_callback, description: “the real-time CPU clock speed”, unit: 'ms')
145 146 147 |
# File 'lib/opentelemetry/metrics/meter.rb', line 145 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) ⇒ nil
ObservableUpDownCounter is an asynchronous Instrument which reports additive value(s) (e.g. the process heap size - it makes sense to report the heap size from multiple processes and sum them up, so we get the total heap usage) when the instrument is being observed.
With this api call:
pf_callback = -> { # collect metrics here } meter.create_observable_up_down_counter(“process.workingset”, pf_callback, description: “process working set”, unit: 'KB')
168 169 170 |
# File 'lib/opentelemetry/metrics/meter.rb', line 168 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) ⇒ nil
UpDownCounter is a synchronous Instrument which supports increments and decrements.
With this api call:
items_counter = meter.create_up_down_counter(“store.inventory”, description: “the number of the items available”, unit: “s”)
100 101 102 |
# File 'lib/opentelemetry/metrics/meter.rb', line 100 def create_up_down_counter(name, unit: nil, description: nil) create_instrument(:up_down_counter, name, unit, description, nil) { UP_DOWN_COUNTER } end |