opentelemetry-metrics-sdk 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/opentelemetry/sdk/metrics/aggregation/aggregation_temporality.rb +25 -0
- data/lib/opentelemetry/sdk/metrics/aggregation/drop.rb +0 -8
- data/lib/opentelemetry/sdk/metrics/aggregation/explicit_bucket_histogram.rb +1 -1
- data/lib/opentelemetry/sdk/metrics/aggregation/exponential_bucket_histogram.rb +6 -4
- data/lib/opentelemetry/sdk/metrics/aggregation/last_value.rb +6 -24
- data/lib/opentelemetry/sdk/metrics/aggregation/sum.rb +2 -2
- data/lib/opentelemetry/sdk/metrics/instrument/observable_counter.rb +1 -1
- data/lib/opentelemetry/sdk/metrics/instrument/observable_up_down_counter.rb +1 -1
- data/lib/opentelemetry/sdk/metrics/instrument/up_down_counter.rb +1 -1
- data/lib/opentelemetry/sdk/metrics/state/metric_stream.rb +2 -1
- data/lib/opentelemetry/sdk/metrics/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6d7be59eeec2cd9ac11018c7d83dae815350d80c428dcb1ce3078b2435c6fc6
|
4
|
+
data.tar.gz: 3f23f0765a8b193ab67beea38c5c52804ab966b5e3d7c0436b4a0960ee9ebbb9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0dac2992b3eca5e5f42a1f503b600155995657e089be8d3bf49918a36b452a049dc8e7fe068e5f18ae9b9b989162d1128fbc28ca5ed96f4b7f183f93026543b4
|
7
|
+
data.tar.gz: 5707defc93ad7cbe2c0f56fabb9d992fe2620b0a2766df43da153ec5cf3b5f46b10089fc7805d02a341314fef134201489f93d52ed2bc223d8beb868c589a6a1
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Release History: opentelemetry-metrics-sdk
|
2
2
|
|
3
|
+
### v0.9.0 / 2025-08-19
|
4
|
+
|
5
|
+
* ADDED: Add `LOWMEMORY` option to `OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE`
|
6
|
+
|
3
7
|
### v0.8.0 / 2025-08-14
|
4
8
|
|
5
9
|
- BREAKING CHANGE: Update default aggregation temporality for counter, histogram, and up down counter to cumulative
|
@@ -28,6 +28,31 @@ module OpenTelemetry
|
|
28
28
|
def cumulative
|
29
29
|
new(CUMULATIVE)
|
30
30
|
end
|
31
|
+
|
32
|
+
# | Preference Value | Counter | Async Counter | Histogram | UpDownCounter | Async UpDownCounter |
|
33
|
+
# |------------------|------------|------------------|----------- |---------------|-------------------- |
|
34
|
+
# | **Cumulative** | Cumulative | Cumulative | Cumulative | Cumulative | Cumulative |
|
35
|
+
# | **Delta** | Delta | Delta | Delta | Cumulative | Cumulative |
|
36
|
+
# | **LowMemory** | Delta | Cumulative | Delta | Cumulative | Cumulative |
|
37
|
+
def determine_temporality(aggregation_temporality: nil, instrument_kind: nil, default: nil)
|
38
|
+
# aggregation_temporality can't be nil because it always has default value in symbol
|
39
|
+
if aggregation_temporality.is_a?(::Symbol)
|
40
|
+
aggregation_temporality == :delta ? delta : cumulative
|
41
|
+
|
42
|
+
elsif aggregation_temporality.is_a?(::String)
|
43
|
+
case aggregation_temporality
|
44
|
+
when 'LOWMEMORY', 'lowmemory', 'low_memory'
|
45
|
+
instrument_kind == :observable_counter ? cumulative : delta
|
46
|
+
when 'DELTA', 'delta'
|
47
|
+
delta
|
48
|
+
when 'CUMULATIVE', 'cumulative'
|
49
|
+
cumulative
|
50
|
+
else
|
51
|
+
default == :delta ? delta : cumulative
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
31
56
|
end
|
32
57
|
|
33
58
|
attr_reader :temporality
|
@@ -10,10 +10,6 @@ module OpenTelemetry
|
|
10
10
|
module Aggregation
|
11
11
|
# Contains the implementation of the Drop aggregation
|
12
12
|
class Drop
|
13
|
-
def initialize
|
14
|
-
@aggregation_temporality = nil
|
15
|
-
end
|
16
|
-
|
17
13
|
def collect(start_time, end_time, data_points)
|
18
14
|
data_points.values.map!(&:dup)
|
19
15
|
end
|
@@ -28,10 +24,6 @@ module OpenTelemetry
|
|
28
24
|
)
|
29
25
|
nil
|
30
26
|
end
|
31
|
-
|
32
|
-
def aggregation_temporality
|
33
|
-
nil
|
34
|
-
end
|
35
27
|
end
|
36
28
|
end
|
37
29
|
end
|
@@ -23,7 +23,7 @@ module OpenTelemetry
|
|
23
23
|
boundaries: DEFAULT_BOUNDARIES,
|
24
24
|
record_min_max: true
|
25
25
|
)
|
26
|
-
@aggregation_temporality = aggregation_temporality
|
26
|
+
@aggregation_temporality = AggregationTemporality.determine_temporality(aggregation_temporality: aggregation_temporality, default: :cumulative)
|
27
27
|
@boundaries = boundaries && !boundaries.empty? ? boundaries.sort : nil
|
28
28
|
@record_min_max = record_min_max
|
29
29
|
end
|
@@ -16,8 +16,6 @@ module OpenTelemetry
|
|
16
16
|
module Aggregation
|
17
17
|
# Contains the implementation of the {https://opentelemetry.io/docs/specs/otel/metrics/data-model/#exponentialhistogram ExponentialBucketHistogram} aggregation
|
18
18
|
class ExponentialBucketHistogram # rubocop:disable Metrics/ClassLength
|
19
|
-
attr_reader :aggregation_temporality
|
20
|
-
|
21
19
|
# relate to min max scale: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#support-a-minimum-and-maximum-scale
|
22
20
|
DEFAULT_SIZE = 160
|
23
21
|
DEFAULT_SCALE = 20
|
@@ -34,7 +32,7 @@ module OpenTelemetry
|
|
34
32
|
record_min_max: true,
|
35
33
|
zero_threshold: 0
|
36
34
|
)
|
37
|
-
@aggregation_temporality = aggregation_temporality
|
35
|
+
@aggregation_temporality = AggregationTemporality.determine_temporality(aggregation_temporality: aggregation_temporality, default: :delta)
|
38
36
|
@record_min_max = record_min_max
|
39
37
|
@min = Float::INFINITY
|
40
38
|
@max = -Float::INFINITY
|
@@ -49,7 +47,7 @@ module OpenTelemetry
|
|
49
47
|
end
|
50
48
|
|
51
49
|
def collect(start_time, end_time, data_points)
|
52
|
-
if @aggregation_temporality
|
50
|
+
if @aggregation_temporality.delta?
|
53
51
|
# Set timestamps and 'move' data point values to result.
|
54
52
|
hdps = data_points.values.map! do |hdp|
|
55
53
|
hdp.start_time_unix_nano = start_time
|
@@ -168,6 +166,10 @@ module OpenTelemetry
|
|
168
166
|
end
|
169
167
|
# rubocop:enable Metrics/MethodLength
|
170
168
|
|
169
|
+
def aggregation_temporality
|
170
|
+
@aggregation_temporality.temporality
|
171
|
+
end
|
172
|
+
|
171
173
|
private
|
172
174
|
|
173
175
|
def grow_buckets(span, buckets)
|
@@ -10,28 +10,14 @@ module OpenTelemetry
|
|
10
10
|
module Aggregation
|
11
11
|
# Contains the implementation of the LastValue aggregation
|
12
12
|
class LastValue
|
13
|
-
def initialize(aggregation_temporality: :delta)
|
14
|
-
@aggregation_temporality = aggregation_temporality == :cumulative ? AggregationTemporality.cumulative : AggregationTemporality.delta
|
15
|
-
end
|
16
|
-
|
17
13
|
def collect(start_time, end_time, data_points)
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
ndp.time_unix_nano = end_time
|
23
|
-
ndp
|
24
|
-
end
|
25
|
-
data_points.clear
|
26
|
-
ndps
|
27
|
-
else
|
28
|
-
# Update timestamps and take a snapshot.
|
29
|
-
data_points.values.map! do |ndp|
|
30
|
-
ndp.start_time_unix_nano ||= start_time # Start time of a data point is from the first observation.
|
31
|
-
ndp.time_unix_nano = end_time
|
32
|
-
ndp.dup
|
33
|
-
end
|
14
|
+
ndps = data_points.values.map! do |ndp|
|
15
|
+
ndp.start_time_unix_nano = start_time
|
16
|
+
ndp.time_unix_nano = end_time
|
17
|
+
ndp
|
34
18
|
end
|
19
|
+
data_points.clear
|
20
|
+
ndps
|
35
21
|
end
|
36
22
|
|
37
23
|
def update(increment, attributes, data_points)
|
@@ -44,10 +30,6 @@ module OpenTelemetry
|
|
44
30
|
)
|
45
31
|
nil
|
46
32
|
end
|
47
|
-
|
48
|
-
def aggregation_temporality
|
49
|
-
@aggregation_temporality.temporality
|
50
|
-
end
|
51
33
|
end
|
52
34
|
end
|
53
35
|
end
|
@@ -11,8 +11,8 @@ module OpenTelemetry
|
|
11
11
|
# Contains the implementation of the Sum aggregation
|
12
12
|
# https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#sum-aggregation
|
13
13
|
class Sum
|
14
|
-
def initialize(aggregation_temporality: ENV.fetch('OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE', :cumulative), monotonic: false)
|
15
|
-
@aggregation_temporality = aggregation_temporality
|
14
|
+
def initialize(aggregation_temporality: ENV.fetch('OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE', :cumulative), monotonic: false, instrument_kind: nil)
|
15
|
+
@aggregation_temporality = AggregationTemporality.determine_temporality(aggregation_temporality: aggregation_temporality, instrument_kind: instrument_kind, default: :cumulative)
|
16
16
|
@monotonic = monotonic
|
17
17
|
end
|
18
18
|
|
@@ -32,7 +32,7 @@ module OpenTelemetry
|
|
32
32
|
private
|
33
33
|
|
34
34
|
def default_aggregation
|
35
|
-
OpenTelemetry::SDK::Metrics::Aggregation::Sum.new(aggregation_temporality: :
|
35
|
+
OpenTelemetry::SDK::Metrics::Aggregation::Sum.new(aggregation_temporality: :cumulative, monotonic: false)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
@@ -35,7 +35,7 @@ module OpenTelemetry
|
|
35
35
|
private
|
36
36
|
|
37
37
|
def default_aggregation
|
38
|
-
OpenTelemetry::SDK::Metrics::Aggregation::Sum.new(monotonic: false)
|
38
|
+
OpenTelemetry::SDK::Metrics::Aggregation::Sum.new(aggregation_temporality: :cumulative, monotonic: false)
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
@@ -72,6 +72,7 @@ module OpenTelemetry
|
|
72
72
|
def aggregate_metric_data(start_time, end_time, aggregation: nil)
|
73
73
|
aggregator = aggregation || @default_aggregation
|
74
74
|
is_monotonic = aggregator.respond_to?(:monotonic?) ? aggregator.monotonic? : nil
|
75
|
+
aggregation_temporality = aggregator.respond_to?(:aggregation_temporality) ? aggregator.aggregation_temporality : nil
|
75
76
|
|
76
77
|
MetricData.new(
|
77
78
|
@name,
|
@@ -81,7 +82,7 @@ module OpenTelemetry
|
|
81
82
|
@meter_provider.resource,
|
82
83
|
@instrumentation_scope,
|
83
84
|
aggregator.collect(start_time, end_time, @data_points),
|
84
|
-
|
85
|
+
aggregation_temporality,
|
85
86
|
start_time,
|
86
87
|
end_time,
|
87
88
|
is_monotonic
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opentelemetry-metrics-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- OpenTelemetry Authors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-08-
|
11
|
+
date: 2025-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opentelemetry-api
|
@@ -251,10 +251,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby
|
|
251
251
|
licenses:
|
252
252
|
- Apache-2.0
|
253
253
|
metadata:
|
254
|
-
changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-metrics-sdk/v0.
|
254
|
+
changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-metrics-sdk/v0.9.0/file.CHANGELOG.html
|
255
255
|
source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/metrics_sdk
|
256
256
|
bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby/issues
|
257
|
-
documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-metrics-sdk/v0.
|
257
|
+
documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-metrics-sdk/v0.9.0
|
258
258
|
post_install_message:
|
259
259
|
rdoc_options: []
|
260
260
|
require_paths:
|