Class: OpenTelemetry::SDK::Metrics::State::MetricStore Private
- Inherits:
-
Object
- Object
- OpenTelemetry::SDK::Metrics::State::MetricStore
- Defined in:
- lib/opentelemetry/sdk/metrics/state/metric_store.rb
Overview
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.
The MetricStore module provides SDK internal functionality that is not a part of the public API.
Instance Method Summary collapse
-
#add_metric_stream(metric_stream) ⇒ Object
private
Registers a metric stream so it is included in future collections.
-
#collect ⇒ Object
private
Collects a snapshot of metric data from all registered metric streams.
-
#initialize(cardinality_limit: nil) ⇒ MetricStore
constructor
private
A new instance of MetricStore.
Constructor Details
#initialize(cardinality_limit: nil) ⇒ MetricStore
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 MetricStore.
16 17 18 19 20 21 22 |
# File 'lib/opentelemetry/sdk/metrics/state/metric_store.rb', line 16 def initialize(cardinality_limit: nil) @mutex = Mutex.new @epoch_start_time = OpenTelemetry::Common::Utilities.time_in_nanoseconds @epoch_end_time = nil @metric_streams = [] @cardinality_limit = cardinality_limit end |
Instance Method Details
#add_metric_stream(metric_stream) ⇒ 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.
Registers a metric stream so it is included in future collections.
36 37 38 39 40 41 42 |
# File 'lib/opentelemetry/sdk/metrics/state/metric_store.rb', line 36 def add_metric_stream(metric_stream) @mutex.synchronize do metric_stream.cardinality_limit = @cardinality_limit @metric_streams = @metric_streams.dup.push(metric_stream) nil end end |
#collect ⇒ 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.
Collects a snapshot of metric data from all registered metric streams.
25 26 27 28 29 30 31 32 33 |
# File 'lib/opentelemetry/sdk/metrics/state/metric_store.rb', line 25 def collect @mutex.synchronize do @epoch_end_time = OpenTelemetry::Common::Utilities.time_in_nanoseconds snapshot = @metric_streams.flat_map { |ms| ms.collect(@epoch_start_time, @epoch_end_time) } @epoch_start_time = @epoch_end_time snapshot end end |