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

#initializeMetricStore

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
# File 'lib/opentelemetry/sdk/metrics/state/metric_store.rb', line 16

def initialize
  @mutex = Mutex.new
  @epoch_start_time = now_in_nano
  @epoch_end_time = nil
  @metric_streams = []
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.



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

def add_metric_stream(metric_stream)
  @mutex.synchronize do
    @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.



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

def collect
  @mutex.synchronize do
    @epoch_end_time = now_in_nano
    # snapshot = @metric_streams.map { |ms| ms.collect(@epoch_start_time, @epoch_end_time) }
    snapshot = @metric_streams.flat_map { |ms| ms.collect(@epoch_start_time, @epoch_end_time) }
    @epoch_start_time = @epoch_end_time
    snapshot
  end
end