Class: OpenTelemetry::SDK::Metrics::Aggregation::AggregationTemporality

Inherits:
Object
  • Object
show all
Defined in:
lib/opentelemetry/sdk/metrics/aggregation/aggregation_temporality.rb

Overview

AggregationTemporality represents the temporality of data point (NumberDataPoint and HistogramDataPoint) in OpenTelemetry::SDK::Metrics. It determine whether the data point will be cleared for each metrics pull/export.

Constant Summary collapse

DELTA =

delta: data point will be cleared after each metrics pull/export.

:delta
CUMULATIVE =

cumulative: data point will NOT be cleared after metrics pull/export.

:cumulative

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(temporality) ⇒ AggregationTemporality

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.

The constructor is private and only for use internally by the class. Users should use the delta and cumulative factory methods to obtain a OpenTelemetry::SDK::Metrics::Aggregation::AggregationTemporality instance.

Parameters:

  • temporality (Integer)

    One of the status codes below



66
67
68
# File 'lib/opentelemetry/sdk/metrics/aggregation/aggregation_temporality.rb', line 66

def initialize(temporality)
  @temporality = temporality
end

Instance Attribute Details

#temporalityObject (readonly)

Returns the value of attribute temporality.



58
59
60
# File 'lib/opentelemetry/sdk/metrics/aggregation/aggregation_temporality.rb', line 58

def temporality
  @temporality
end

Class Method Details

.cumulativeAggregationTemporality

Returns a newly created OpenTelemetry::SDK::Metrics::Aggregation::AggregationTemporality with temporality == CUMULATIVE



28
29
30
# File 'lib/opentelemetry/sdk/metrics/aggregation/aggregation_temporality.rb', line 28

def cumulative
  new(CUMULATIVE)
end

.deltaAggregationTemporality

Returns a newly created OpenTelemetry::SDK::Metrics::Aggregation::AggregationTemporality with temporality == DELTA



21
22
23
# File 'lib/opentelemetry/sdk/metrics/aggregation/aggregation_temporality.rb', line 21

def delta
  new(DELTA)
end

.determine_temporality(aggregation_temporality: nil, instrument_kind: nil, default: nil) ⇒ Object

| Preference Value | Counter | Async Counter | Histogram | UpDownCounter | Async UpDownCounter | |——————|————|——————|———– |—————|——————– | | Cumulative | Cumulative | Cumulative | Cumulative | Cumulative | Cumulative | | Delta | Delta | Delta | Delta | Cumulative | Cumulative | | LowMemory | Delta | Cumulative | Delta | Cumulative | Cumulative |



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

def determine_temporality(aggregation_temporality: nil, instrument_kind: nil, default: nil)
  # aggregation_temporality can't be nil because it always has default value in symbol
  if aggregation_temporality.is_a?(::Symbol)
    aggregation_temporality == :delta ? delta : cumulative

  elsif aggregation_temporality.is_a?(::String)
    case aggregation_temporality
    when 'LOWMEMORY', 'lowmemory', 'low_memory'
      instrument_kind == :observable_counter ? cumulative : delta
    when 'DELTA', 'delta'
      delta
    when 'CUMULATIVE', 'cumulative'
      cumulative
    else
      default == :delta ? delta : cumulative
    end

  end
end

Instance Method Details

#cumulative?Boolean

Returns:

  • (Boolean)


74
75
76
# File 'lib/opentelemetry/sdk/metrics/aggregation/aggregation_temporality.rb', line 74

def cumulative?
  @temporality == :cumulative
end

#delta?Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/opentelemetry/sdk/metrics/aggregation/aggregation_temporality.rb', line 70

def delta?
  @temporality == :delta
end