Class: OpenTelemetry::SDK::Metrics::Export::InMemoryMetricPullExporter

Inherits:
MetricReader
  • Object
show all
Defined in:
lib/opentelemetry/sdk/metrics/export/in_memory_metric_pull_exporter.rb

Overview

The InMemoryMetricPullExporter behaves as a Metric Reader and Exporter. To be used for testing purposes, not production.

Instance Attribute Summary collapse

Attributes inherited from MetricReader

#metric_store

Instance Method Summary collapse

Methods inherited from MetricReader

#collect, #force_flush

Constructor Details

#initializeInMemoryMetricPullExporter

Returns a new instance of InMemoryMetricPullExporter.



16
17
18
19
20
# File 'lib/opentelemetry/sdk/metrics/export/in_memory_metric_pull_exporter.rb', line 16

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

Instance Attribute Details

#metric_snapshotsObject (readonly)

Returns the value of attribute metric_snapshots.



14
15
16
# File 'lib/opentelemetry/sdk/metrics/export/in_memory_metric_pull_exporter.rb', line 14

def metric_snapshots
  @metric_snapshots
end

Instance Method Details

#export(metrics, timeout: nil) ⇒ Object



26
27
28
29
30
31
# File 'lib/opentelemetry/sdk/metrics/export/in_memory_metric_pull_exporter.rb', line 26

def export(metrics, timeout: nil)
  @mutex.synchronize do
    @metric_snapshots.concat(Array(metrics))
  end
  SUCCESS
end

#pullObject



22
23
24
# File 'lib/opentelemetry/sdk/metrics/export/in_memory_metric_pull_exporter.rb', line 22

def pull
  export(collect)
end

#resetObject



33
34
35
36
37
# File 'lib/opentelemetry/sdk/metrics/export/in_memory_metric_pull_exporter.rb', line 33

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

#shutdownObject



39
40
41
# File 'lib/opentelemetry/sdk/metrics/export/in_memory_metric_pull_exporter.rb', line 39

def shutdown
  SUCCESS
end