Class: OpenTelemetry::SDK::Metrics::State::MetricStream Private

Inherits:
Object
  • Object
show all
Defined in:
lib/opentelemetry/sdk/metrics/state/metric_stream.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 MetricStream class provides SDK internal functionality that is not a part of the public API.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, description, unit, instrument_kind, meter_provider, instrumentation_scope, aggregation) ⇒ MetricStream

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 MetricStream.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/opentelemetry/sdk/metrics/state/metric_stream.rb', line 18

def initialize(
  name,
  description,
  unit,
  instrument_kind,
  meter_provider,
  instrumentation_scope,
  aggregation
)
  @name = name
  @description = description
  @unit = unit
  @instrument_kind = instrument_kind
  @meter_provider = meter_provider
  @instrumentation_scope = instrumentation_scope
  @aggregation = aggregation

  @mutex = Mutex.new
end

Instance Attribute Details

#data_pointsObject (readonly)

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.



16
17
18
# File 'lib/opentelemetry/sdk/metrics/state/metric_stream.rb', line 16

def data_points
  @data_points
end

#descriptionObject (readonly)

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.



16
17
18
# File 'lib/opentelemetry/sdk/metrics/state/metric_stream.rb', line 16

def description
  @description
end

#instrument_kindObject (readonly)

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.



16
17
18
# File 'lib/opentelemetry/sdk/metrics/state/metric_stream.rb', line 16

def instrument_kind
  @instrument_kind
end

#instrumentation_scopeObject (readonly)

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.



16
17
18
# File 'lib/opentelemetry/sdk/metrics/state/metric_stream.rb', line 16

def instrumentation_scope
  @instrumentation_scope
end

#nameObject (readonly)

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.



16
17
18
# File 'lib/opentelemetry/sdk/metrics/state/metric_stream.rb', line 16

def name
  @name
end

#unitObject (readonly)

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.



16
17
18
# File 'lib/opentelemetry/sdk/metrics/state/metric_stream.rb', line 16

def unit
  @unit
end

Instance Method Details

#collect(start_time, end_time) ⇒ 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.



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/opentelemetry/sdk/metrics/state/metric_stream.rb', line 38

def collect(start_time, end_time)
  @mutex.synchronize do
    MetricData.new(
      @name,
      @description,
      @unit,
      @instrument_kind,
      @meter_provider.resource,
      @instrumentation_scope,
      @aggregation.collect(start_time, end_time),
      @aggregation.aggregation_temporality,
      start_time,
      end_time
    )
  end
end

#to_sObject

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.



59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/opentelemetry/sdk/metrics/state/metric_stream.rb', line 59

def to_s
  instrument_info = String.new
  instrument_info << "name=#{@name}"
  instrument_info << " description=#{@description}" if @description
  instrument_info << " unit=#{@unit}" if @unit
  @data_points.map do |attributes, value|
    metric_stream_string = String.new
    metric_stream_string << instrument_info
    metric_stream_string << " attributes=#{attributes}" if attributes
    metric_stream_string << " #{value}"
    metric_stream_string
  end.join("\n")
end

#update(value, attributes) ⇒ 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.



55
56
57
# File 'lib/opentelemetry/sdk/metrics/state/metric_stream.rb', line 55

def update(value, attributes)
  @mutex.synchronize { @aggregation.update(value, attributes) }
end