opentelemetry-metrics-sdk 0.2.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ce5f31c7463140b3dee9d8209ded3c831964b3b6a0edff4837ec5308481d6fc3
4
- data.tar.gz: 4c900df8d7e8eb7f8c783ad73c11136a0931d21f447c75daaa254a51653e8cb2
3
+ metadata.gz: 45746399ac9cf72000a4a5531a1bb151731fd6fcb3354385d8821a6d9b109cce
4
+ data.tar.gz: 7da59da17348fc19abb319da95964a5902154b54eab28ca54166f971e3d366ea
5
5
  SHA512:
6
- metadata.gz: 84702ecb88071fa4d30803cdc7e71656643eb73593a4783d98fef7d1350955d03c7a3b17e5a50a61e3cc10726eb25dd6e234170ea979347c42893fb0f18abd15
7
- data.tar.gz: 6072767e9f13652e20e376971f8c327ef52b8ef2a8d0e149819574cc5caaae0addb4d313b583e894a3c71b06ddd2bf264c030bca58a41309a359895cc0b5f8eb
6
+ metadata.gz: f8a0095dda549fea543c7049e5cf228809ae5f67e449c6a1d11933fb1f1849b10a06200682c4fd52b016e9dc4ff2159236abeec9120d5997e56b76f34f6d11f7
7
+ data.tar.gz: 858df23a2dac33a1567a78aec7b6fac4c6afa02f274e8e5b2828d329f4073aa51cfe15277161be87fcc33402828fe20d9bc9f25b6ad2ac1999bb117a9a2fdac3
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Release History: opentelemetry-metrics-sdk
2
2
 
3
+ ### v0.4.0 / 2024-11-19
4
+
5
+ * ADDED: Update metrics configuration patch
6
+
7
+ ### v0.3.0 / 2024-10-22
8
+
9
+ * ADDED: Add basic metrics view
10
+ * FIXED: Coerce aggregation_temporality to symbol
11
+ * FIXED: Add warning if invalid meter name given
12
+
3
13
  ### v0.2.0 / 2024-08-27
4
14
 
5
15
  * ADDED: Add basic periodic exporting metric_reader
data/README.md CHANGED
@@ -15,6 +15,7 @@ Metrics is one of the core signals in OpenTelemetry. This package allows you to
15
15
  This gem does not have a full implementation of the Metrics SDK specification. The work is in progress.
16
16
 
17
17
  At this time, you should be able to:
18
+
18
19
  * Create synchronous:
19
20
  * counters
20
21
  * up down counters
@@ -26,6 +27,7 @@ At this time, you should be able to:
26
27
  * Use delta aggregation temporality
27
28
 
28
29
  We do not yet have support for:
30
+
29
31
  * Asynchronous instruments
30
32
  * Cumulative aggregation temporality
31
33
  * Metrics Views
@@ -41,7 +43,7 @@ Until the Ruby implementation of OpenTelemetry Metrics becomes stable, the funct
41
43
 
42
44
  Install the gems using:
43
45
 
44
- ```
46
+ ```sh
45
47
  gem install opentelemetry-metrics-sdk
46
48
  gem install opentelemetry-sdk
47
49
  ```
@@ -97,7 +99,6 @@ During this experimental stage, we're looking for lots of community feedback abo
97
99
 
98
100
  The `opentelemetry-metrics-sdk` gem is distributed under the Apache 2.0 license. See [LICENSE][license-github] for more information.
99
101
 
100
-
101
102
  [metrics-sdk]: https://opentelemetry.io/docs/specs/otel/metrics/sdk/
102
103
  [opentelemetry-home]: https://opentelemetry.io
103
104
  [bundler-home]: https://bundler.io
@@ -0,0 +1,37 @@
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 Aggregation
11
+ # Contains the implementation of the Drop aggregation
12
+ class Drop
13
+ attr_reader :aggregation_temporality
14
+
15
+ def initialize(aggregation_temporality: :delta)
16
+ @aggregation_temporality = aggregation_temporality
17
+ end
18
+
19
+ def collect(start_time, end_time, data_points)
20
+ data_points.values.map!(&:dup)
21
+ end
22
+
23
+ def update(increment, attributes, data_points)
24
+ data_points[attributes] = NumberDataPoint.new(
25
+ {},
26
+ 0,
27
+ 0,
28
+ 0,
29
+ 0
30
+ )
31
+ nil
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -25,25 +25,25 @@ module OpenTelemetry
25
25
  boundaries: DEFAULT_BOUNDARIES,
26
26
  record_min_max: true
27
27
  )
28
- @data_points = {}
29
- @aggregation_temporality = aggregation_temporality
28
+
29
+ @aggregation_temporality = aggregation_temporality.to_sym
30
30
  @boundaries = boundaries && !boundaries.empty? ? boundaries.sort : nil
31
31
  @record_min_max = record_min_max
32
32
  end
33
33
 
34
- def collect(start_time, end_time)
34
+ def collect(start_time, end_time, data_points)
35
35
  if @aggregation_temporality == :delta
36
36
  # Set timestamps and 'move' data point values to result.
37
- hdps = @data_points.values.map! do |hdp|
37
+ hdps = data_points.values.map! do |hdp|
38
38
  hdp.start_time_unix_nano = start_time
39
39
  hdp.time_unix_nano = end_time
40
40
  hdp
41
41
  end
42
- @data_points.clear
42
+ data_points.clear
43
43
  hdps
44
44
  else
45
45
  # Update timestamps and take a snapshot.
46
- @data_points.values.map! do |hdp|
46
+ data_points.values.map! do |hdp|
47
47
  hdp.start_time_unix_nano ||= start_time # Start time of a data point is from the first observation.
48
48
  hdp.time_unix_nano = end_time
49
49
  hdp = hdp.dup
@@ -53,14 +53,14 @@ module OpenTelemetry
53
53
  end
54
54
  end
55
55
 
56
- def update(amount, attributes)
57
- hdp = @data_points.fetch(attributes) do
56
+ def update(amount, attributes, data_points)
57
+ hdp = data_points.fetch(attributes) do
58
58
  if @record_min_max
59
59
  min = Float::INFINITY
60
60
  max = -Float::INFINITY
61
61
  end
62
62
 
63
- @data_points[attributes] = HistogramDataPoint.new(
63
+ data_points[attributes] = HistogramDataPoint.new(
64
64
  attributes,
65
65
  nil, # :start_time_unix_nano
66
66
  nil, # :time_unix_nano
@@ -0,0 +1,53 @@
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 Aggregation
11
+ # Contains the implementation of the LastValue aggregation
12
+ class LastValue
13
+ attr_reader :aggregation_temporality
14
+
15
+ def initialize(aggregation_temporality: :delta)
16
+ @aggregation_temporality = aggregation_temporality
17
+ end
18
+
19
+ def collect(start_time, end_time, data_points)
20
+ if @aggregation_temporality == :delta
21
+ # Set timestamps and 'move' data point values to result.
22
+ ndps = data_points.values.map! do |ndp|
23
+ ndp.start_time_unix_nano = start_time
24
+ ndp.time_unix_nano = end_time
25
+ ndp
26
+ end
27
+ data_points.clear
28
+ ndps
29
+ else
30
+ # Update timestamps and take a snapshot.
31
+ data_points.values.map! do |ndp|
32
+ ndp.start_time_unix_nano ||= start_time # Start time of a data point is from the first observation.
33
+ ndp.time_unix_nano = end_time
34
+ ndp.dup
35
+ end
36
+ end
37
+ end
38
+
39
+ def update(increment, attributes, data_points)
40
+ data_points[attributes] = NumberDataPoint.new(
41
+ attributes,
42
+ nil,
43
+ nil,
44
+ increment,
45
+ nil
46
+ )
47
+ nil
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -15,23 +15,22 @@ module OpenTelemetry
15
15
 
16
16
  def initialize(aggregation_temporality: ENV.fetch('OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE', :delta))
17
17
  # TODO: the default should be :cumulative, see issue #1555
18
- @aggregation_temporality = aggregation_temporality
19
- @data_points = {}
18
+ @aggregation_temporality = aggregation_temporality.to_sym
20
19
  end
21
20
 
22
- def collect(start_time, end_time)
21
+ def collect(start_time, end_time, data_points)
23
22
  if @aggregation_temporality == :delta
24
23
  # Set timestamps and 'move' data point values to result.
25
- ndps = @data_points.values.map! do |ndp|
24
+ ndps = data_points.values.map! do |ndp|
26
25
  ndp.start_time_unix_nano = start_time
27
26
  ndp.time_unix_nano = end_time
28
27
  ndp
29
28
  end
30
- @data_points.clear
29
+ data_points.clear
31
30
  ndps
32
31
  else
33
32
  # Update timestamps and take a snapshot.
34
- @data_points.values.map! do |ndp|
33
+ data_points.values.map! do |ndp|
35
34
  ndp.start_time_unix_nano ||= start_time # Start time of a data point is from the first observation.
36
35
  ndp.time_unix_nano = end_time
37
36
  ndp.dup
@@ -39,8 +38,8 @@ module OpenTelemetry
39
38
  end
40
39
  end
41
40
 
42
- def update(increment, attributes)
43
- ndp = @data_points[attributes] || @data_points[attributes] = NumberDataPoint.new(
41
+ def update(increment, attributes, data_points)
42
+ ndp = data_points[attributes] || data_points[attributes] = NumberDataPoint.new(
44
43
  attributes,
45
44
  nil,
46
45
  nil,
@@ -19,3 +19,5 @@ require 'opentelemetry/sdk/metrics/aggregation/number_data_point'
19
19
  require 'opentelemetry/sdk/metrics/aggregation/histogram_data_point'
20
20
  require 'opentelemetry/sdk/metrics/aggregation/explicit_bucket_histogram'
21
21
  require 'opentelemetry/sdk/metrics/aggregation/sum'
22
+ require 'opentelemetry/sdk/metrics/aggregation/last_value'
23
+ require 'opentelemetry/sdk/metrics/aggregation/drop'
@@ -10,12 +10,47 @@ module OpenTelemetry
10
10
  # The ConfiguratorPatch implements a hook to configure the metrics
11
11
  # portion of the SDK.
12
12
  module ConfiguratorPatch
13
+ def add_metric_reader(metric_reader)
14
+ @metric_readers << metric_reader
15
+ end
16
+
13
17
  private
14
18
 
15
- # The metrics_configuration_hook method is where we define the setup process
16
- # for metrics SDK.
19
+ def initialize
20
+ super
21
+ @metric_readers = []
22
+ end
23
+
24
+ # The metrics_configuration_hook method is where we define the setup process for the metrics SDK.
17
25
  def metrics_configuration_hook
18
26
  OpenTelemetry.meter_provider = Metrics::MeterProvider.new(resource: @resource)
27
+ configure_metric_readers
28
+ end
29
+
30
+ def configure_metric_readers
31
+ readers = @metric_readers.empty? ? wrapped_metric_exporters_from_env.compact : @metric_readers
32
+ readers.each { |r| OpenTelemetry.meter_provider.add_metric_reader(r) }
33
+ end
34
+
35
+ def wrapped_metric_exporters_from_env
36
+ exporters = ENV.fetch('OTEL_METRICS_EXPORTER', 'otlp')
37
+ exporters.split(',').map do |exporter|
38
+ case exporter.strip
39
+ when 'none' then nil
40
+ when 'console' then OpenTelemetry.meter_provider.add_metric_reader(Metrics::Export::PeriodicMetricReader.new(exporter: Metrics::Export::ConsoleMetricPullExporter.new))
41
+ when 'in-memory' then OpenTelemetry.meter_provider.add_metric_reader(Metrics::Export::InMemoryMetricPullExporter.new)
42
+ when 'otlp'
43
+ begin
44
+ OpenTelemetry.meter_provider.add_metric_reader(Metrics::Export::PeriodicMetricReader.new(exporter: OpenTelemetry::Exporter::OTLP::Metrics::MetricsExporter.new))
45
+ rescue NameError
46
+ OpenTelemetry.logger.warn 'The otlp metrics exporter cannot be configured - please add opentelemetry-exporter-otlp-metrics to your Gemfile, metrics will not be exported'
47
+ nil
48
+ end
49
+ else
50
+ OpenTelemetry.logger.warn "The #{exporter} exporter is unknown and cannot be configured, metrics will not be exported"
51
+ nil
52
+ end
53
+ end
19
54
  end
20
55
  end
21
56
  end
@@ -25,7 +25,7 @@ module OpenTelemetry
25
25
 
26
26
  def export(metrics, timeout: nil)
27
27
  @mutex.synchronize do
28
- @metric_snapshots << metrics
28
+ @metric_snapshots.concat(Array(metrics))
29
29
  end
30
30
  SUCCESS
31
31
  end
@@ -24,7 +24,7 @@ module OpenTelemetry
24
24
  # Values must be non-nil and (array of) string, boolean or numeric type.
25
25
  # Array values must not contain nil elements and all elements must be of
26
26
  # the same basic type (string, numeric, boolean).
27
- def record(amount, attributes: nil)
27
+ def record(amount, attributes: {})
28
28
  update(amount, attributes)
29
29
  nil
30
30
  rescue StandardError => e
@@ -24,7 +24,7 @@ module OpenTelemetry
24
24
  # Values must be non-nil and (array of) string, boolean or numeric type.
25
25
  # Array values must not contain nil elements and all elements must be of
26
26
  # the same basic type (string, numeric, boolean).
27
- def add(amount, attributes: nil)
27
+ def add(amount, attributes: {})
28
28
  update(amount, attributes)
29
29
  nil
30
30
  rescue StandardError => e
@@ -11,6 +11,8 @@ module OpenTelemetry
11
11
  module Metrics
12
12
  # {Meter} is the SDK implementation of {OpenTelemetry::Metrics::Meter}.
13
13
  class Meter < OpenTelemetry::Metrics::Meter
14
+ NAME_REGEX = /\A[a-zA-Z][-.\w]{0,62}\z/
15
+
14
16
  # @api private
15
17
  #
16
18
  # Returns a new {Meter} instance.
@@ -34,6 +36,12 @@ module OpenTelemetry
34
36
  end
35
37
 
36
38
  def create_instrument(kind, name, unit, description, callback)
39
+ raise InstrumentNameError if name.nil?
40
+ raise InstrumentNameError if name.empty?
41
+ raise InstrumentNameError unless NAME_REGEX.match?(name)
42
+ raise InstrumentUnitError if unit && (!unit.ascii_only? || unit.size > 63)
43
+ raise InstrumentDescriptionError if description && (description.size > 1023 || !utf8mb3_encoding?(description.dup))
44
+
37
45
  super do
38
46
  case kind
39
47
  when :counter then OpenTelemetry::SDK::Metrics::Instrument::Counter.new(name, unit, description, @instrumentation_scope, @meter_provider)
@@ -45,6 +53,11 @@ module OpenTelemetry
45
53
  end
46
54
  end
47
55
  end
56
+
57
+ def utf8mb3_encoding?(string)
58
+ string.force_encoding('UTF-8').valid_encoding? &&
59
+ string.each_char { |c| return false if c.bytesize >= 4 }
60
+ end
48
61
  end
49
62
  end
50
63
  end
@@ -14,7 +14,7 @@ module OpenTelemetry
14
14
  Key = Struct.new(:name, :version)
15
15
  private_constant(:Key)
16
16
 
17
- attr_reader :resource, :metric_readers
17
+ attr_reader :resource, :metric_readers, :registered_views
18
18
 
19
19
  def initialize(resource: OpenTelemetry::SDK::Resources::Resource.create)
20
20
  @mutex = Mutex.new
@@ -22,6 +22,7 @@ module OpenTelemetry
22
22
  @stopped = false
23
23
  @metric_readers = []
24
24
  @resource = resource
25
+ @registered_views = []
25
26
  end
26
27
 
27
28
  # Returns a {Meter} instance.
@@ -36,6 +37,7 @@ module OpenTelemetry
36
37
  OpenTelemetry.logger.warn 'calling MeterProvider#meter after shutdown, a noop meter will be returned.'
37
38
  OpenTelemetry::Metrics::Meter.new
38
39
  else
40
+ OpenTelemetry.logger.warn "Invalid meter name provided: #{name.nil? ? 'nil' : 'empty'} value" if name.to_s.empty?
39
41
  @mutex.synchronize { @meter_registry[Key.new(name, version)] ||= Meter.new(name, version, self) }
40
42
  end
41
43
  end
@@ -125,13 +127,30 @@ module OpenTelemetry
125
127
  end
126
128
  end
127
129
 
128
- # The type of the Instrument(s) (optional).
129
- # The name of the Instrument(s). OpenTelemetry SDK authors MAY choose to support wildcard characters, with the question mark (?) matching exactly one character and the asterisk character (*) matching zero or more characters.
130
- # The name of the Meter (optional).
131
- # The version of the Meter (optional).
132
- # The schema_url of the Meter (optional).
133
- def add_view
134
- # TODO: For each meter add this view to all applicable instruments
130
+ # A View provides SDK users with the flexibility to customize the metrics that are output by the SDK.
131
+ #
132
+ # Example:
133
+ #
134
+ # OpenTelemetry.meter_provider.add_view('test', :aggregation => Aggregation::Drop.new,
135
+ # :type => :counter, :unit => 'smidgen',
136
+ # :meter_name => 'test', :meter_version => '1.0')
137
+ #
138
+ #
139
+ # @param [String] name Name of the view.
140
+ # @param [optional Hash] options For more precise matching, {View} and {MetricsStream}
141
+ # options may include:
142
+ # aggregation: An instance of an aggregation class, e.g. {ExplicitBucketHistogram}, {Sum}, {LastValue}
143
+ # type: A Symbol representing the instrument kind, e.g. :observable_gauge, :counter
144
+ # unit: A String matching an instrumentation unit, e.g. 'smidgen'
145
+ # meter_name: A String matching a meter name, e.g. meter_provider.meter('sample_meter_name', version: '1.2.0'), would be 'sample_meter_name'
146
+ # meter_version: A String matching a meter version, e.g. meter_provider.meter('sample_meter_name', version: '1.2.0'), would be '1.2.0'
147
+ #
148
+ # @return [nil] returns nil
149
+ #
150
+ def add_view(name, **options)
151
+ # TODO: add schema_url as part of options
152
+ @registered_views << View::RegisteredView.new(name, **options)
153
+ nil
135
154
  end
136
155
  end
137
156
  end
@@ -23,7 +23,8 @@ module OpenTelemetry
23
23
  def collect
24
24
  @mutex.synchronize do
25
25
  @epoch_end_time = now_in_nano
26
- snapshot = @metric_streams.map { |ms| ms.collect(@epoch_start_time, @epoch_end_time) }
26
+ # snapshot = @metric_streams.map { |ms| ms.collect(@epoch_start_time, @epoch_end_time) }
27
+ snapshot = @metric_streams.flat_map { |ms| ms.collect(@epoch_start_time, @epoch_end_time) }
27
28
  @epoch_start_time = @epoch_end_time
28
29
  snapshot
29
30
  end
@@ -30,30 +30,61 @@ module OpenTelemetry
30
30
  @instrument_kind = instrument_kind
31
31
  @meter_provider = meter_provider
32
32
  @instrumentation_scope = instrumentation_scope
33
- @aggregation = aggregation
33
+ @default_aggregation = aggregation
34
+ @data_points = {}
35
+ @registered_views = []
34
36
 
37
+ find_registered_view
35
38
  @mutex = Mutex.new
36
39
  end
37
40
 
38
41
  def collect(start_time, end_time)
39
42
  @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
- )
43
+ metric_data = []
44
+ if @registered_views.empty?
45
+ metric_data << aggregate_metric_data(start_time, end_time)
46
+ else
47
+ @registered_views.each { |view| metric_data << aggregate_metric_data(start_time, end_time, aggregation: view.aggregation) }
48
+ end
49
+
50
+ metric_data
52
51
  end
53
52
  end
54
53
 
55
54
  def update(value, attributes)
56
- @mutex.synchronize { @aggregation.update(value, attributes) }
55
+ if @registered_views.empty?
56
+ @mutex.synchronize { @default_aggregation.update(value, attributes, @data_points) }
57
+ else
58
+ @registered_views.each do |view|
59
+ @mutex.synchronize do
60
+ attributes ||= {}
61
+ attributes.merge!(view.attribute_keys)
62
+ view.aggregation.update(value, attributes, @data_points) if view.valid_aggregation?
63
+ end
64
+ end
65
+ end
66
+ end
67
+
68
+ def aggregate_metric_data(start_time, end_time, aggregation: nil)
69
+ aggregator = aggregation || @default_aggregation
70
+ MetricData.new(
71
+ @name,
72
+ @description,
73
+ @unit,
74
+ @instrument_kind,
75
+ @meter_provider.resource,
76
+ @instrumentation_scope,
77
+ aggregator.collect(start_time, end_time, @data_points),
78
+ aggregator.aggregation_temporality,
79
+ start_time,
80
+ end_time
81
+ )
82
+ end
83
+
84
+ def find_registered_view
85
+ return if @meter_provider.nil?
86
+
87
+ @meter_provider.registered_views.each { |view| @registered_views << view if view.match_instrument?(self) }
57
88
  end
58
89
 
59
90
  def to_s
@@ -8,7 +8,7 @@ module OpenTelemetry
8
8
  module SDK
9
9
  module Metrics
10
10
  # Current OpenTelemetry metrics sdk version
11
- VERSION = '0.2.0'
11
+ VERSION = '0.4.0'
12
12
  end
13
13
  end
14
14
  end
@@ -0,0 +1,58 @@
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 View
11
+ # RegisteredView is an internal class used to match Views with a given {MetricStream}
12
+ class RegisteredView
13
+ attr_reader :name, :aggregation, :attribute_keys, :regex
14
+
15
+ def initialize(name, **options)
16
+ @name = name
17
+ @options = options
18
+ @aggregation = options[:aggregation]
19
+ @attribute_keys = options[:attribute_keys] || {}
20
+
21
+ generate_regex_pattern(name)
22
+ end
23
+
24
+ def match_instrument?(metric_stream)
25
+ return false if @name && !name_match(metric_stream.name)
26
+ return false if @options[:type] && @options[:type] != metric_stream.instrument_kind
27
+ return false if @options[:unit] && @options[:unit] != metric_stream.unit
28
+ return false if @options[:meter_name] && @options[:meter_name] != metric_stream.instrumentation_scope.name
29
+ return false if @options[:meter_version] && @options[:meter_version] != metric_stream.instrumentation_scope.version
30
+
31
+ true
32
+ end
33
+
34
+ def name_match(stream_name)
35
+ !!@regex&.match(stream_name)
36
+ end
37
+
38
+ def valid_aggregation?
39
+ @aggregation.class.name.rpartition('::')[0] == 'OpenTelemetry::SDK::Metrics::Aggregation'
40
+ end
41
+
42
+ private
43
+
44
+ def generate_regex_pattern(view_name)
45
+ regex_pattern = Regexp.escape(view_name)
46
+
47
+ regex_pattern.gsub!('\*', '.*')
48
+ regex_pattern.gsub!('\?', '.')
49
+
50
+ @regex = Regexp.new("^#{regex_pattern}$")
51
+ rescue StandardError
52
+ @regex = nil
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,17 @@
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
+ # A View provides SDK users with the flexibility to customize the metrics that are output by the SDK.
11
+ module View
12
+ end
13
+ end
14
+ end
15
+ end
16
+
17
+ require 'opentelemetry/sdk/metrics/view/registered_view'
@@ -20,3 +20,4 @@ require 'opentelemetry/sdk/metrics/instrument'
20
20
  require 'opentelemetry/sdk/metrics/meter'
21
21
  require 'opentelemetry/sdk/metrics/meter_provider'
22
22
  require 'opentelemetry/sdk/metrics/state'
23
+ require 'opentelemetry/sdk/metrics/view'
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.2.0
4
+ version: 0.4.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: 2024-08-28 00:00:00.000000000 Z
11
+ date: 2024-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opentelemetry-api
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: opentelemetry-metrics-api
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 0.1.1
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 0.1.1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: opentelemetry-sdk
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -206,8 +206,10 @@ files:
206
206
  - lib/opentelemetry-metrics-sdk.rb
207
207
  - lib/opentelemetry/sdk/metrics.rb
208
208
  - lib/opentelemetry/sdk/metrics/aggregation.rb
209
+ - lib/opentelemetry/sdk/metrics/aggregation/drop.rb
209
210
  - lib/opentelemetry/sdk/metrics/aggregation/explicit_bucket_histogram.rb
210
211
  - lib/opentelemetry/sdk/metrics/aggregation/histogram_data_point.rb
212
+ - lib/opentelemetry/sdk/metrics/aggregation/last_value.rb
211
213
  - lib/opentelemetry/sdk/metrics/aggregation/number_data_point.rb
212
214
  - lib/opentelemetry/sdk/metrics/aggregation/sum.rb
213
215
  - lib/opentelemetry/sdk/metrics/configuration_patch.rb
@@ -231,14 +233,16 @@ files:
231
233
  - lib/opentelemetry/sdk/metrics/state/metric_store.rb
232
234
  - lib/opentelemetry/sdk/metrics/state/metric_stream.rb
233
235
  - lib/opentelemetry/sdk/metrics/version.rb
236
+ - lib/opentelemetry/sdk/metrics/view.rb
237
+ - lib/opentelemetry/sdk/metrics/view/registered_view.rb
234
238
  homepage: https://github.com/open-telemetry/opentelemetry-ruby
235
239
  licenses:
236
240
  - Apache-2.0
237
241
  metadata:
238
- changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-metrics-sdk/v0.2.0/file.CHANGELOG.html
242
+ changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-metrics-sdk/v0.4.0/file.CHANGELOG.html
239
243
  source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/metrics_sdk
240
244
  bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby/issues
241
- documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-metrics-sdk/v0.2.0
245
+ documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-metrics-sdk/v0.4.0
242
246
  post_install_message:
243
247
  rdoc_options: []
244
248
  require_paths: