Class: OpenTelemetry::SDK::Metrics::State::MetricStore Private

Inherits:
Object
  • Object
show all
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

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.



34
35
36
37
38
39
40
# File 'lib/opentelemetry/sdk/metrics/state/metric_store.rb', line 34

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

#collectObject

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.



24
25
26
27
28
29
30
31
32
# File 'lib/opentelemetry/sdk/metrics/state/metric_store.rb', line 24

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