opentelemetry-metrics-sdk 0.5.0 → 0.6.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 +16 -7
- data/README.md +1 -1
- data/lib/opentelemetry/sdk/metrics/aggregation/sum.rb +8 -1
- data/lib/opentelemetry/sdk/metrics/export/periodic_metric_reader.rb +38 -8
- data/lib/opentelemetry/sdk/metrics/instrument/counter.rb +1 -1
- data/lib/opentelemetry/sdk/metrics/instrument/up_down_counter.rb +1 -1
- data/lib/opentelemetry/sdk/metrics/state/metric_data.rb +2 -1
- data/lib/opentelemetry/sdk/metrics/state/metric_stream.rb +4 -1
- data/lib/opentelemetry/sdk/metrics/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f80c6d95eeb420fc59002214a2486d588027050dd75c3e675946b52e13db1623
|
4
|
+
data.tar.gz: 401efba2cf641811e0bd21db5f9d1ba73ec41d876a859d98009c1a4a148a38b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3f55fad01c447ce033120386ccb5c0841585aba1e787c7865477a398d1502f098bfdb566918eb29e38e8bae83eb9c2903657d32a7e834331a7cbae3a0ccf055
|
7
|
+
data.tar.gz: 265d205ecbfac906c2cdd3d0c29e86b3e2c1b53568c544da0283d1dd71fee40e88d0084d41b28a0aab60f33c79a00db8b2cccfa12df127d822b4547032e6e21c
|
data/CHANGELOG.md
CHANGED
@@ -1,26 +1,35 @@
|
|
1
1
|
# Release History: opentelemetry-metrics-sdk
|
2
2
|
|
3
|
+
### v0.6.1 / 2025-04-09
|
4
|
+
|
5
|
+
* FIXED: Use condition signal to replace sleep and remove timeout.timeout…
|
6
|
+
|
7
|
+
### v0.6.0 / 2025-02-25
|
8
|
+
|
9
|
+
- ADDED: Support 3.1 Min Version
|
10
|
+
- FIXED: Add is_monotonic flag to sum
|
11
|
+
|
3
12
|
### v0.5.0 / 2025-01-08
|
4
13
|
|
5
|
-
|
14
|
+
- ADDED: Add synchronous gauge
|
6
15
|
|
7
16
|
### v0.4.1 / 2024-12-04
|
8
17
|
|
9
|
-
|
18
|
+
- FIXED: Handle float value in NumberDataPoint
|
10
19
|
|
11
20
|
### v0.4.0 / 2024-11-20
|
12
21
|
|
13
|
-
|
22
|
+
- ADDED: Update metrics configuration patch
|
14
23
|
|
15
24
|
### v0.3.0 / 2024-10-22
|
16
25
|
|
17
|
-
|
18
|
-
|
19
|
-
|
26
|
+
- ADDED: Add basic metrics view
|
27
|
+
- FIXED: Coerce aggregation_temporality to symbol
|
28
|
+
- FIXED: Add warning if invalid meter name given
|
20
29
|
|
21
30
|
### v0.2.0 / 2024-08-27
|
22
31
|
|
23
|
-
|
32
|
+
- ADDED: Add basic periodic exporting metric_reader
|
24
33
|
|
25
34
|
### v0.1.0 / 2024-07-31
|
26
35
|
|
data/README.md
CHANGED
@@ -25,6 +25,7 @@ At this time, you should be able to:
|
|
25
25
|
* observable up down counters
|
26
26
|
* Export using a pull exporter
|
27
27
|
* Use delta aggregation temporality
|
28
|
+
* Periodic Exporting Metric Reader
|
28
29
|
|
29
30
|
We do not yet have support for:
|
30
31
|
|
@@ -32,7 +33,6 @@ We do not yet have support for:
|
|
32
33
|
* Cumulative aggregation temporality
|
33
34
|
* Metrics Views
|
34
35
|
* Metrics Exemplars
|
35
|
-
* Periodic Exporting Metric Reader
|
36
36
|
* Push metric exporting
|
37
37
|
|
38
38
|
These lists are incomplete and are intended to give a broad description of what's available.
|
@@ -13,9 +13,10 @@ module OpenTelemetry
|
|
13
13
|
class Sum
|
14
14
|
attr_reader :aggregation_temporality
|
15
15
|
|
16
|
-
def initialize(aggregation_temporality: ENV.fetch('OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE', :delta))
|
16
|
+
def initialize(aggregation_temporality: ENV.fetch('OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE', :delta), monotonic: false)
|
17
17
|
# TODO: the default should be :cumulative, see issue #1555
|
18
18
|
@aggregation_temporality = aggregation_temporality.to_sym
|
19
|
+
@monotonic = monotonic
|
19
20
|
end
|
20
21
|
|
21
22
|
def collect(start_time, end_time, data_points)
|
@@ -38,7 +39,13 @@ module OpenTelemetry
|
|
38
39
|
end
|
39
40
|
end
|
40
41
|
|
42
|
+
def monotonic?
|
43
|
+
@monotonic
|
44
|
+
end
|
45
|
+
|
41
46
|
def update(increment, attributes, data_points)
|
47
|
+
return if @monotonic && increment < 0
|
48
|
+
|
42
49
|
ndp = data_points[attributes] || data_points[attributes] = NumberDataPoint.new(
|
43
50
|
attributes,
|
44
51
|
nil,
|
@@ -33,14 +33,22 @@ module OpenTelemetry
|
|
33
33
|
@thread = nil
|
34
34
|
@continue = false
|
35
35
|
@mutex = Mutex.new
|
36
|
+
@condition = ConditionVariable.new
|
36
37
|
@export_mutex = Mutex.new
|
37
38
|
|
38
39
|
start
|
39
40
|
end
|
40
41
|
|
42
|
+
# Shuts the @thread down and set @continue to false; it will block
|
43
|
+
# until the shutdown thread is finished.
|
44
|
+
#
|
45
|
+
# @param [optional Numeric] timeout An optional timeout in seconds.
|
46
|
+
# @return [Integer] SUCCESS if no error occurred, FAILURE if a
|
47
|
+
# non-specific failure occurred.
|
41
48
|
def shutdown(timeout: nil)
|
42
49
|
thread = lock do
|
43
50
|
@continue = false # force termination in next iteration
|
51
|
+
@condition.signal
|
44
52
|
@thread
|
45
53
|
end
|
46
54
|
thread&.join(@export_interval)
|
@@ -52,15 +60,35 @@ module OpenTelemetry
|
|
52
60
|
Export::FAILURE
|
53
61
|
end
|
54
62
|
|
63
|
+
# Export all metrics to the configured `Exporter` that have not yet
|
64
|
+
# been exported.
|
65
|
+
#
|
66
|
+
# This method should only be called in cases where it is absolutely
|
67
|
+
# necessary, such as when using some FaaS providers that may suspend
|
68
|
+
# the process after an invocation, but before the `PeriodicMetricReader` exports
|
69
|
+
# the completed metrics.
|
70
|
+
#
|
71
|
+
# @param [optional Numeric] timeout An optional timeout in seconds.
|
72
|
+
# @return [Integer] SUCCESS if no error occurred, FAILURE if a
|
73
|
+
# non-specific failure occurred.
|
55
74
|
def force_flush(timeout: nil)
|
56
|
-
export(timeout:
|
75
|
+
export(timeout:)
|
57
76
|
Export::SUCCESS
|
58
77
|
rescue StandardError
|
59
78
|
Export::FAILURE
|
60
79
|
end
|
61
80
|
|
81
|
+
# Check both @thread and @continue object to determine if current
|
82
|
+
# PeriodicMetricReader is still alive. If one of them is true/alive,
|
83
|
+
# then PeriodicMetricReader is determined as alive
|
84
|
+
def alive?
|
85
|
+
@continue || @thread.alive?
|
86
|
+
end
|
87
|
+
|
62
88
|
private
|
63
89
|
|
90
|
+
# Start a thread that continously export metrics within fixed duration.
|
91
|
+
# The wait mechanism is using to check @mutex lock with conditional variable
|
64
92
|
def start
|
65
93
|
@continue = true
|
66
94
|
if @exporter.nil?
|
@@ -70,19 +98,21 @@ module OpenTelemetry
|
|
70
98
|
else
|
71
99
|
@thread = Thread.new do
|
72
100
|
while @continue
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
export(timeout: @export_timeout)
|
77
|
-
end
|
78
|
-
rescue Timeout::Error => e
|
79
|
-
OpenTelemetry.handle_error(exception: e, message: 'PeriodicMetricReader timeout.')
|
101
|
+
lock do
|
102
|
+
@condition.wait(@mutex, @export_interval)
|
103
|
+
export(timeout: @export_timeout)
|
80
104
|
end
|
81
105
|
end
|
82
106
|
end
|
83
107
|
end
|
84
108
|
end
|
85
109
|
|
110
|
+
# Helper function for the defined exporter to export metrics.
|
111
|
+
# It only exports if the collected metrics are not an empty array (collect returns an Array).
|
112
|
+
#
|
113
|
+
# @param [optional Numeric] timeout An optional timeout in seconds.
|
114
|
+
# @return [Integer] SUCCESS if no error occurred, FAILURE if a
|
115
|
+
# non-specific failure occurred
|
86
116
|
def export(timeout: nil)
|
87
117
|
@export_mutex.synchronize do
|
88
118
|
collected_metrics = collect
|
@@ -18,7 +18,8 @@ module OpenTelemetry
|
|
18
18
|
:data_points, # Hash{Hash{String => String, Numeric, Boolean, Array<String, Numeric, Boolean>} => Numeric}
|
19
19
|
:aggregation_temporality, # Symbol
|
20
20
|
:start_time_unix_nano, # Integer nanoseconds since Epoch
|
21
|
-
:time_unix_nano
|
21
|
+
:time_unix_nano, # Integer nanoseconds since Epoch
|
22
|
+
:is_monotonic) # Boolean
|
22
23
|
end
|
23
24
|
end
|
24
25
|
end
|
@@ -67,6 +67,8 @@ module OpenTelemetry
|
|
67
67
|
|
68
68
|
def aggregate_metric_data(start_time, end_time, aggregation: nil)
|
69
69
|
aggregator = aggregation || @default_aggregation
|
70
|
+
is_monotonic = aggregator.respond_to?(:monotonic?) ? aggregator.monotonic? : nil
|
71
|
+
|
70
72
|
MetricData.new(
|
71
73
|
@name,
|
72
74
|
@description,
|
@@ -77,7 +79,8 @@ module OpenTelemetry
|
|
77
79
|
aggregator.collect(start_time, end_time, @data_points),
|
78
80
|
aggregator.aggregation_temporality,
|
79
81
|
start_time,
|
80
|
-
end_time
|
82
|
+
end_time,
|
83
|
+
is_monotonic
|
81
84
|
)
|
82
85
|
end
|
83
86
|
|
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.6.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-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opentelemetry-api
|
@@ -240,10 +240,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby
|
|
240
240
|
licenses:
|
241
241
|
- Apache-2.0
|
242
242
|
metadata:
|
243
|
-
changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-metrics-sdk/v0.
|
243
|
+
changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-metrics-sdk/v0.6.1/file.CHANGELOG.html
|
244
244
|
source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/metrics_sdk
|
245
245
|
bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby/issues
|
246
|
-
documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-metrics-sdk/v0.
|
246
|
+
documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-metrics-sdk/v0.6.1
|
247
247
|
post_install_message:
|
248
248
|
rdoc_options: []
|
249
249
|
require_paths:
|
@@ -252,14 +252,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
252
252
|
requirements:
|
253
253
|
- - ">="
|
254
254
|
- !ruby/object:Gem::Version
|
255
|
-
version: '3.
|
255
|
+
version: '3.1'
|
256
256
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
257
257
|
requirements:
|
258
258
|
- - ">="
|
259
259
|
- !ruby/object:Gem::Version
|
260
260
|
version: '0'
|
261
261
|
requirements: []
|
262
|
-
rubygems_version: 3.
|
262
|
+
rubygems_version: 3.3.27
|
263
263
|
signing_key:
|
264
264
|
specification_version: 4
|
265
265
|
summary: A stats collection and distributed tracing framework
|