Sha256: f0060c9fa60418985fa2948db4d6be1086fb25eb94b8d868d969b73beb15734f
Contents?: true
Size: 1.17 KB
Versions: 2
Compression:
Stored size: 1.17 KB
Contents
# frozen_string_literal: true # Copyright The OpenTelemetry Authors # # SPDX-License-Identifier: Apache-2.0 module OpenTelemetry module SDK module Metrics module State # @api private # # The MetricStore module provides SDK internal functionality that is not a part of the # public API. class MetricStore def initialize @mutex = Mutex.new @epoch_start_time = now_in_nano @epoch_end_time = nil @metric_streams = [] end def collect @mutex.synchronize do @epoch_end_time = now_in_nano snapshot = @metric_streams.map { |ms| ms.collect(@epoch_start_time, @epoch_end_time) } @epoch_start_time = @epoch_end_time snapshot end end def add_metric_stream(metric_stream) @mutex.synchronize do @metric_streams = @metric_streams.dup.push(metric_stream) nil end end private def now_in_nano (Time.now.to_r * 1_000_000_000).to_i end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
opentelemetry-metrics-sdk-0.2.0 | lib/opentelemetry/sdk/metrics/state/metric_store.rb |
opentelemetry-metrics-sdk-0.1.0 | lib/opentelemetry/sdk/metrics/state/metric_store.rb |