Class: OpenTelemetry::SDK::Metrics::Instrument::SynchronousInstrument

Inherits:
Object
  • Object
show all
Defined in:
lib/opentelemetry/sdk/metrics/instrument/synchronous_instrument.rb

Overview

SynchronousInstrument contains the common functionality shared across the synchronous instruments SDK instruments.

Direct Known Subclasses

Counter, Histogram, UpDownCounter

Instance Method Summary collapse

Constructor Details

#initialize(name, unit, description, instrumentation_scope, meter_provider) ⇒ SynchronousInstrument

Returns a new instance of SynchronousInstrument.

[View source]

14
15
16
17
18
19
20
21
22
23
# File 'lib/opentelemetry/sdk/metrics/instrument/synchronous_instrument.rb', line 14

def initialize(name, unit, description, instrumentation_scope, meter_provider)
  @name = name
  @unit = unit
  @description = description
  @instrumentation_scope = instrumentation_scope
  @meter_provider = meter_provider
  @metric_streams = []

  meter_provider.register_synchronous_instrument(self)
end

Instance Method Details

#register_with_new_metric_store(metric_store, aggregation: default_aggregation) ⇒ 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.

[View source]

26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/opentelemetry/sdk/metrics/instrument/synchronous_instrument.rb', line 26

def register_with_new_metric_store(metric_store, aggregation: default_aggregation)
  ms = OpenTelemetry::SDK::Metrics::State::MetricStream.new(
    @name,
    @description,
    @unit,
    instrument_kind,
    @meter_provider,
    @instrumentation_scope,
    aggregation
  )
  @metric_streams << ms
  metric_store.add_metric_stream(ms)
end