opentelemetry-metrics-sdk 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +9 -0
  3. data/CHANGELOG.md +5 -0
  4. data/LICENSE +201 -0
  5. data/README.md +110 -0
  6. data/lib/opentelemetry/sdk/metrics/aggregation/explicit_bucket_histogram.rb +100 -0
  7. data/lib/opentelemetry/sdk/metrics/aggregation/histogram_data_point.rb +27 -0
  8. data/lib/opentelemetry/sdk/metrics/aggregation/number_data_point.rb +19 -0
  9. data/lib/opentelemetry/sdk/metrics/aggregation/sum.rb +58 -0
  10. data/lib/opentelemetry/sdk/metrics/aggregation.rb +21 -0
  11. data/lib/opentelemetry/sdk/metrics/configuration_patch.rb +25 -0
  12. data/lib/opentelemetry/sdk/metrics/export/console_metric_pull_exporter.rb +44 -0
  13. data/lib/opentelemetry/sdk/metrics/export/in_memory_metric_pull_exporter.rb +46 -0
  14. data/lib/opentelemetry/sdk/metrics/export/metric_reader.rb +36 -0
  15. data/lib/opentelemetry/sdk/metrics/export.rb +28 -0
  16. data/lib/opentelemetry/sdk/metrics/instrument/counter.rb +51 -0
  17. data/lib/opentelemetry/sdk/metrics/instrument/histogram.rb +44 -0
  18. data/lib/opentelemetry/sdk/metrics/instrument/observable_counter.rb +26 -0
  19. data/lib/opentelemetry/sdk/metrics/instrument/observable_gauge.rb +26 -0
  20. data/lib/opentelemetry/sdk/metrics/instrument/observable_up_down_counter.rb +26 -0
  21. data/lib/opentelemetry/sdk/metrics/instrument/synchronous_instrument.rb +49 -0
  22. data/lib/opentelemetry/sdk/metrics/instrument/up_down_counter.rb +44 -0
  23. data/lib/opentelemetry/sdk/metrics/instrument.rb +22 -0
  24. data/lib/opentelemetry/sdk/metrics/meter.rb +51 -0
  25. data/lib/opentelemetry/sdk/metrics/meter_provider.rb +139 -0
  26. data/lib/opentelemetry/sdk/metrics/state/metric_data.rb +25 -0
  27. data/lib/opentelemetry/sdk/metrics/state/metric_store.rb +48 -0
  28. data/lib/opentelemetry/sdk/metrics/state/metric_stream.rb +76 -0
  29. data/lib/opentelemetry/sdk/metrics/state.rb +22 -0
  30. data/lib/opentelemetry/sdk/metrics/version.rb +14 -0
  31. data/lib/opentelemetry/sdk/metrics.rb +22 -0
  32. data/lib/opentelemetry-metrics-sdk.rb +9 -0
  33. metadata +260 -0
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright The OpenTelemetry Authors
4
+ #
5
+ # SPDX-License-Identifier: Apache-2.0
6
+
7
+ module OpenTelemetry
8
+ module SDK
9
+ module Metrics
10
+ module State
11
+ # @api private
12
+ #
13
+ # The MetricStream class provides SDK internal functionality that is not a part of the
14
+ # public API.
15
+ class MetricStream
16
+ attr_reader :name, :description, :unit, :instrument_kind, :instrumentation_scope, :data_points
17
+
18
+ def initialize(
19
+ name,
20
+ description,
21
+ unit,
22
+ instrument_kind,
23
+ meter_provider,
24
+ instrumentation_scope,
25
+ aggregation
26
+ )
27
+ @name = name
28
+ @description = description
29
+ @unit = unit
30
+ @instrument_kind = instrument_kind
31
+ @meter_provider = meter_provider
32
+ @instrumentation_scope = instrumentation_scope
33
+ @aggregation = aggregation
34
+
35
+ @mutex = Mutex.new
36
+ end
37
+
38
+ def collect(start_time, end_time)
39
+ @mutex.synchronize do
40
+ MetricData.new(
41
+ @name,
42
+ @description,
43
+ @unit,
44
+ @instrument_kind,
45
+ @meter_provider.resource,
46
+ @instrumentation_scope,
47
+ @aggregation.collect(start_time, end_time),
48
+ @aggregation.aggregation_temporality,
49
+ start_time,
50
+ end_time
51
+ )
52
+ end
53
+ end
54
+
55
+ def update(value, attributes)
56
+ @mutex.synchronize { @aggregation.update(value, attributes) }
57
+ end
58
+
59
+ def to_s
60
+ instrument_info = String.new
61
+ instrument_info << "name=#{@name}"
62
+ instrument_info << " description=#{@description}" if @description
63
+ instrument_info << " unit=#{@unit}" if @unit
64
+ @data_points.map do |attributes, value|
65
+ metric_stream_string = String.new
66
+ metric_stream_string << instrument_info
67
+ metric_stream_string << " attributes=#{attributes}" if attributes
68
+ metric_stream_string << " #{value}"
69
+ metric_stream_string
70
+ end.join("\n")
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright The OpenTelemetry Authors
4
+ #
5
+ # SPDX-License-Identifier: Apache-2.0
6
+
7
+ module OpenTelemetry
8
+ module SDK
9
+ module Metrics
10
+ # @api private
11
+ #
12
+ # The State module provides SDK internal functionality that is not a part of the
13
+ # public API.
14
+ module State
15
+ end
16
+ end
17
+ end
18
+ end
19
+
20
+ require 'opentelemetry/sdk/metrics/state/metric_data'
21
+ require 'opentelemetry/sdk/metrics/state/metric_store'
22
+ require 'opentelemetry/sdk/metrics/state/metric_stream'
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright The OpenTelemetry Authors
4
+ #
5
+ # SPDX-License-Identifier: Apache-2.0
6
+
7
+ module OpenTelemetry
8
+ module SDK
9
+ module Metrics
10
+ # Current OpenTelemetry metrics sdk version
11
+ VERSION = '0.1.0'
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright The OpenTelemetry Authors
4
+ #
5
+ # SPDX-License-Identifier: Apache-2.0
6
+
7
+ module OpenTelemetry
8
+ module SDK
9
+ # The Metrics module contains the OpenTelemetry metrics reference
10
+ # implementation.
11
+ module Metrics
12
+ end
13
+ end
14
+ end
15
+
16
+ require 'opentelemetry/sdk/metrics/aggregation'
17
+ require 'opentelemetry/sdk/metrics/configuration_patch'
18
+ require 'opentelemetry/sdk/metrics/export'
19
+ require 'opentelemetry/sdk/metrics/instrument'
20
+ require 'opentelemetry/sdk/metrics/meter'
21
+ require 'opentelemetry/sdk/metrics/meter_provider'
22
+ require 'opentelemetry/sdk/metrics/state'
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright The OpenTelemetry Authors
4
+ #
5
+ # SPDX-License-Identifier: Apache-2.0
6
+
7
+ require 'opentelemetry/sdk'
8
+ require 'opentelemetry-metrics-api'
9
+ require 'opentelemetry/sdk/metrics'
metadata ADDED
@@ -0,0 +1,260 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: opentelemetry-metrics-sdk
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - OpenTelemetry Authors
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-07-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: opentelemetry-api
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: opentelemetry-metrics-api
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: opentelemetry-sdk
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.2'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.2'
55
+ - !ruby/object:Gem::Dependency
56
+ name: benchmark-ipsa
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.2.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.2.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '1.17'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '1.17'
83
+ - !ruby/object:Gem::Dependency
84
+ name: faraday
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.13'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.13'
97
+ - !ruby/object:Gem::Dependency
98
+ name: minitest
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '5.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '5.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: opentelemetry-test-helpers
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rake
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '12.0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '12.0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rubocop
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: 1.51.0
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: 1.51.0
153
+ - !ruby/object:Gem::Dependency
154
+ name: simplecov
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '0.17'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '0.17'
167
+ - !ruby/object:Gem::Dependency
168
+ name: yard
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: '0.9'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: '0.9'
181
+ - !ruby/object:Gem::Dependency
182
+ name: yard-doctest
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: 0.1.6
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: 0.1.6
195
+ description: A stats collection and distributed tracing framework
196
+ email:
197
+ - cncf-opentelemetry-contributors@lists.cncf.io
198
+ executables: []
199
+ extensions: []
200
+ extra_rdoc_files: []
201
+ files:
202
+ - ".yardopts"
203
+ - CHANGELOG.md
204
+ - LICENSE
205
+ - README.md
206
+ - lib/opentelemetry-metrics-sdk.rb
207
+ - lib/opentelemetry/sdk/metrics.rb
208
+ - lib/opentelemetry/sdk/metrics/aggregation.rb
209
+ - lib/opentelemetry/sdk/metrics/aggregation/explicit_bucket_histogram.rb
210
+ - lib/opentelemetry/sdk/metrics/aggregation/histogram_data_point.rb
211
+ - lib/opentelemetry/sdk/metrics/aggregation/number_data_point.rb
212
+ - lib/opentelemetry/sdk/metrics/aggregation/sum.rb
213
+ - lib/opentelemetry/sdk/metrics/configuration_patch.rb
214
+ - lib/opentelemetry/sdk/metrics/export.rb
215
+ - lib/opentelemetry/sdk/metrics/export/console_metric_pull_exporter.rb
216
+ - lib/opentelemetry/sdk/metrics/export/in_memory_metric_pull_exporter.rb
217
+ - lib/opentelemetry/sdk/metrics/export/metric_reader.rb
218
+ - lib/opentelemetry/sdk/metrics/instrument.rb
219
+ - lib/opentelemetry/sdk/metrics/instrument/counter.rb
220
+ - lib/opentelemetry/sdk/metrics/instrument/histogram.rb
221
+ - lib/opentelemetry/sdk/metrics/instrument/observable_counter.rb
222
+ - lib/opentelemetry/sdk/metrics/instrument/observable_gauge.rb
223
+ - lib/opentelemetry/sdk/metrics/instrument/observable_up_down_counter.rb
224
+ - lib/opentelemetry/sdk/metrics/instrument/synchronous_instrument.rb
225
+ - lib/opentelemetry/sdk/metrics/instrument/up_down_counter.rb
226
+ - lib/opentelemetry/sdk/metrics/meter.rb
227
+ - lib/opentelemetry/sdk/metrics/meter_provider.rb
228
+ - lib/opentelemetry/sdk/metrics/state.rb
229
+ - lib/opentelemetry/sdk/metrics/state/metric_data.rb
230
+ - lib/opentelemetry/sdk/metrics/state/metric_store.rb
231
+ - lib/opentelemetry/sdk/metrics/state/metric_stream.rb
232
+ - lib/opentelemetry/sdk/metrics/version.rb
233
+ homepage: https://github.com/open-telemetry/opentelemetry-ruby
234
+ licenses:
235
+ - Apache-2.0
236
+ metadata:
237
+ changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-metrics-sdk/v0.1.0/file.CHANGELOG.html
238
+ source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/metrics_sdk
239
+ bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby/issues
240
+ documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-metrics-sdk/v0.1.0
241
+ post_install_message:
242
+ rdoc_options: []
243
+ require_paths:
244
+ - lib
245
+ required_ruby_version: !ruby/object:Gem::Requirement
246
+ requirements:
247
+ - - ">="
248
+ - !ruby/object:Gem::Version
249
+ version: '3.0'
250
+ required_rubygems_version: !ruby/object:Gem::Requirement
251
+ requirements:
252
+ - - ">="
253
+ - !ruby/object:Gem::Version
254
+ version: '0'
255
+ requirements: []
256
+ rubygems_version: 3.2.33
257
+ signing_key:
258
+ specification_version: 4
259
+ summary: A stats collection and distributed tracing framework
260
+ test_files: []