opentelemetry-metrics-sdk 0.8.0 → 0.9.1
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 +8 -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 +8 -5
- 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: 640af5c30dd7768db2a34210e70ec4119396363462fa7494f35148986c1cc09a
|
4
|
+
data.tar.gz: 73d7f52d0553d61e695c933e1fe38d39e9eff7b3c08002e4f9286470d575b65c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b73aaf5a8193508dc2194206c29c969c2e21793b6986b592cb605cdd98992df8bd4cea571715d75ce6fe4fff980dbccff7cca913da486956115fbab3e3e691d
|
7
|
+
data.tar.gz: '08155ce74455222fd9d49a922578fa4171a9fe98be081751dcfc5c27d3bb58e9925124f9886686ae09ef68dcc7b9cd8165a805d0fcb02a87723748fe0f37ad27'
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Release History: opentelemetry-metrics-sdk
|
2
2
|
|
3
|
+
### v0.9.1 / 2025-09-16
|
4
|
+
|
5
|
+
* FIXED: Use mapping scale outside of rescale logic
|
6
|
+
|
7
|
+
### v0.9.0 / 2025-08-19
|
8
|
+
|
9
|
+
* ADDED: Add `LOWMEMORY` option to `OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE`
|
10
|
+
|
3
11
|
### v0.8.0 / 2025-08-14
|
4
12
|
|
5
13
|
- 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
|
@@ -142,13 +140,14 @@ module OpenTelemetry
|
|
142
140
|
scale_change = get_scale_change(low, high)
|
143
141
|
downscale(scale_change, hdp.positive, hdp.negative)
|
144
142
|
new_scale = @mapping.scale - scale_change
|
145
|
-
hdp.scale = new_scale
|
146
143
|
@mapping = new_mapping(new_scale)
|
147
144
|
bucket_index = @mapping.map_to_index(amount)
|
148
145
|
|
149
146
|
OpenTelemetry.logger.debug "Rescaled with new scale #{new_scale} from #{low} and #{high}; bucket_index is updated to #{bucket_index}"
|
150
147
|
end
|
151
148
|
|
149
|
+
hdp.scale = @mapping.scale
|
150
|
+
|
152
151
|
# adjust buckets based on the bucket_index
|
153
152
|
if bucket_index < buckets.index_start
|
154
153
|
span = buckets.index_end - bucket_index
|
@@ -168,6 +167,10 @@ module OpenTelemetry
|
|
168
167
|
end
|
169
168
|
# rubocop:enable Metrics/MethodLength
|
170
169
|
|
170
|
+
def aggregation_temporality
|
171
|
+
@aggregation_temporality.temporality
|
172
|
+
end
|
173
|
+
|
171
174
|
private
|
172
175
|
|
173
176
|
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.1
|
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-
|
11
|
+
date: 2025-09-16 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.1/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.1
|
258
258
|
post_install_message:
|
259
259
|
rdoc_options: []
|
260
260
|
require_paths:
|