Sha256: 3358ea05d23a0c85d607e0c42c893fad79df18302999085e754159e9839a9d36

Contents?: true

Size: 985 Bytes

Versions: 1

Compression:

Stored size: 985 Bytes

Contents

# frozen_string_literal: true

# Copyright The OpenTelemetry Authors
#
# SPDX-License-Identifier: Apache-2.0

module OpenTelemetry
  module SDK
    module Metrics
      module Export
        # The InMemoryMetricPullExporter behaves as a Metric Reader and Exporter.
        # To be used for testing purposes, not production.
        class InMemoryMetricPullExporter < MetricReader
          attr_reader :metric_snapshots

          def initialize
            super
            @metric_snapshots = []
            @mutex = Mutex.new
          end

          def pull
            export(collect)
          end

          def export(metrics)
            @mutex.synchronize do
              @metric_snapshots << metrics
            end
            SUCCESS
          end

          def reset
            @mutex.synchronize do
              @metric_snapshots.clear
            end
          end

          def shutdown
            SUCCESS
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
opentelemetry-metrics-sdk-0.1.0 lib/opentelemetry/sdk/metrics/export/in_memory_metric_pull_exporter.rb