opentelemetry-sdk 1.12.1 → 1.13.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 669386368dd472621a23b59729c2f3dc99922866a87b91d88ff244803e5a8eb9
4
- data.tar.gz: d7d0216e2c302e33bd021d44853b93f91b371d3a0b55049ce218cdba3ac76e95
3
+ metadata.gz: d263c7e1224cad3b9e7a9ac1fc958dae76c9bc9788df4dde53b56d5603cfd22e
4
+ data.tar.gz: e2a8d6e023dfbc277b37bd0df76a4903adab343e3b3be2173a6943806141904d
5
5
  SHA512:
6
- metadata.gz: e590e765a30272482a56cf3de76ae778fbc8218648ec4b8920ae274e39f2a7e57dc501ec13cbb1bbe8dce767306f6f1250538122f7745e133d4a89a7e8b17ed6
7
- data.tar.gz: 8a2d22ae1202b742a5284eddf4cc9e4cca16fd19f76abec30cef8a54cb9a242803bf1c2643a713656b1b370abd3884d74aa091dc04780ae614c3c81680749510
6
+ metadata.gz: '088ced3e6d379e35df9790f999287ecca88c2f79ac7b4c8bdf162c89e8e19bca49bebd1d084ff4dfe872e2d70aaad1b0c8dd1c11e0e1686fd297b05d42f3435f'
7
+ data.tar.gz: 7b1c670d348ba097b8721c3b30843ceb693d62985e8e798d9589e87792d85388c7d32cd2c618c90317f53a780f2199a6916b07fc817456fec3c0c431f90e442e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Release History: opentelemetry-sdk
2
2
 
3
+ ### v1.13.0 / 2026-07-21
4
+
5
+ * ADDED: Add attributes support to instrumentation scope for tracers (#2094)
6
+
3
7
  ### v1.12.1 / 2026-07-08
4
8
 
5
9
  * DOCS: Update source for gemspec links to RubyDoc (#2123)
@@ -190,11 +190,11 @@ module OpenTelemetry
190
190
  when 'otlp'
191
191
  otlp_protocol = ENV['OTEL_EXPORTER_OTLP_TRACES_PROTOCOL'] || ENV['OTEL_EXPORTER_OTLP_PROTOCOL'] || 'http/protobuf'
192
192
 
193
- if otlp_protocol != 'http/protobuf'
193
+ if otlp_protocol == 'http/protobuf'
194
+ fetch_exporter(exporter, 'OpenTelemetry::Exporter::OTLP::Exporter')
195
+ else
194
196
  OpenTelemetry.logger.warn "The #{otlp_protocol} transport protocol is not supported by the OTLP exporter, spans will not be exported."
195
197
  nil
196
- else
197
- fetch_exporter(exporter, 'OpenTelemetry::Exporter::OTLP::Exporter')
198
198
  end
199
199
  when 'jaeger' then fetch_exporter(exporter, 'OpenTelemetry::Exporter::Jaeger::CollectorExporter')
200
200
  when 'zipkin' then fetch_exporter(exporter, 'OpenTelemetry::Exporter::Zipkin::Exporter')
@@ -8,6 +8,7 @@ module OpenTelemetry
8
8
  module SDK
9
9
  # InstrumentationScope is a struct containing scope information for export.
10
10
  InstrumentationScope = Struct.new(:name,
11
- :version)
11
+ :version,
12
+ :attributes)
12
13
  end
13
14
  end
@@ -34,7 +34,7 @@ module OpenTelemetry
34
34
 
35
35
  case value.first
36
36
  when String
37
- value.all? { |v| v.instance_of?(String) }
37
+ value.all?(String)
38
38
  when TrueClass, FalseClass
39
39
  value.all? { |v| boolean?(v) }
40
40
  when Numeric
@@ -210,9 +210,11 @@ module OpenTelemetry
210
210
  end
211
211
 
212
212
  def lock
213
+ # rubocop:disable Style/ExplicitBlockArgument
213
214
  @mutex.synchronize do
214
215
  yield
215
216
  end
217
+ # rubocop:enable Style/ExplicitBlockArgument
216
218
  end
217
219
  end
218
220
  end
@@ -418,7 +418,7 @@ module OpenTelemetry
418
418
  excess_link_count = valid_links.size - link_count_limit
419
419
  valid_links.pop(excess_link_count) if excess_link_count.positive?
420
420
  valid_links.map! do |link|
421
- attrs = Hash[link.attributes] # link.attributes is frozen, so we need an unfrozen copy to adjust.
421
+ attrs = link.attributes.to_h.dup # link.attributes is frozen, so we need an unfrozen copy to adjust.
422
422
  attrs.keep_if { |key, value| Internal.valid_key?(key) && Internal.valid_value?(value) }
423
423
  excess = attrs.size - link_attribute_count_limit
424
424
  excess.times { attrs.shift } if excess.positive?
@@ -444,7 +444,7 @@ module OpenTelemetry
444
444
 
445
445
  excess = event.attributes.size - event_attribute_count_limit
446
446
  if excess.positive? || !valid_attributes
447
- attrs = Hash[event.attributes] # event.attributes is frozen, so we need an unfrozen copy to adjust.
447
+ attrs = event.attributes.to_h.dup # event.attributes is frozen, so we need an unfrozen copy to adjust.
448
448
  attrs.keep_if { |key, value| Internal.valid_key?(key) && Internal.valid_value?(value) }
449
449
  excess = attrs.size - event_attribute_count_limit
450
450
  excess.times { attrs.shift } if excess.positive?
@@ -13,13 +13,15 @@ module OpenTelemetry
13
13
  #
14
14
  # Returns a new {Tracer} instance.
15
15
  #
16
- # @param [String] name Instrumentation package name
17
- # @param [String] version Instrumentation package version
16
+ # @param [String] name Instrumentation scope name
17
+ # @param [String] version Instrumentation scope version
18
18
  # @param [TracerProvider] tracer_provider TracerProvider that initialized the tracer
19
+ # @param [Hash{String => String, Numeric, Boolean, Array<String, Numeric, Boolean>}] attributes
20
+ # Instrumentation scope attributes
19
21
  #
20
22
  # @return [Tracer]
21
- def initialize(name, version, tracer_provider)
22
- @instrumentation_scope = InstrumentationScope.new(name, version)
23
+ def initialize(name, version, tracer_provider, attributes: nil)
24
+ @instrumentation_scope = InstrumentationScope.new(name, version, attributes || {}.freeze)
23
25
  @tracer_provider = tracer_provider
24
26
  end
25
27
 
@@ -9,8 +9,10 @@ module OpenTelemetry
9
9
  module Trace
10
10
  # {TracerProvider} is the SDK implementation of {OpenTelemetry::Trace::TracerProvider}.
11
11
  class TracerProvider < OpenTelemetry::Trace::TracerProvider # rubocop:disable Metrics/ClassLength
12
- Key = Struct.new(:name, :version)
13
- private_constant(:Key)
12
+ Key = Struct.new(:name, :version, :attributes)
13
+ EMPTY_ATTRIBUTES = {}.freeze
14
+
15
+ private_constant(:Key, :EMPTY_ATTRIBUTES)
14
16
 
15
17
  attr_accessor :span_limits, :id_generator, :sampler
16
18
  attr_reader :resource
@@ -44,15 +46,28 @@ module OpenTelemetry
44
46
 
45
47
  # Returns a {Tracer} instance.
46
48
  #
47
- # @param [optional String] name Instrumentation package name
48
- # @param [optional String] version Instrumentation package version
49
+ # Supports both positional arguments (legacy) and keyword arguments:
50
+ # tracer('name', '1.0') # legacy positional
51
+ # tracer(name: 'name', version: '1.0', attributes: {...}) # keyword
52
+ #
53
+ # When both positional and keyword arguments are provided for the same
54
+ # parameter, the keyword argument takes precedence.
55
+ #
56
+ # @param [String] name Instrumentation scope name
57
+ # @param [String] version Instrumentation scope version
58
+ # @param [Hash{String => String, Numeric, Boolean, Array<String, Numeric, Boolean>}] attributes
59
+ # Instrumentation scope attributes
49
60
  #
50
61
  # @return [Tracer]
51
- def tracer(name = nil, version = nil)
52
- name ||= ''
53
- version ||= ''
62
+ def tracer(deprecated_name = nil, deprecated_version = nil, name: nil, version: nil, attributes: nil) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
63
+ name ||= deprecated_name || ''
64
+ version ||= deprecated_version || ''
65
+ attributes = attributes&.dup&.freeze || EMPTY_ATTRIBUTES
54
66
  OpenTelemetry.logger.warn 'calling TracerProvider#tracer without providing a tracer name.' if name.empty?
55
- @registry_mutex.synchronize { @registry[Key.new(name, version)] ||= Tracer.new(name, version, self) }
67
+ @registry_mutex.synchronize do
68
+ @registry[Key.new(name, version, attributes)] ||=
69
+ Tracer.new(name, version, self, attributes: attributes)
70
+ end
56
71
  end
57
72
 
58
73
  # Attempts to stop all the activity for this {TracerProvider}. Calls
@@ -7,6 +7,6 @@
7
7
  module OpenTelemetry
8
8
  module SDK
9
9
  ## Current OpenTelemetry version
10
- VERSION = '1.12.1'
10
+ VERSION = '1.13.0'
11
11
  end
12
12
  end
@@ -23,7 +23,7 @@ module OpenTelemetry
23
23
  # ConfigurationError is an exception type used to wrap configuration errors
24
24
  # passed to OpenTelemetry.error_handler. This can be used to distinguish
25
25
  # errors reported during SDK configuration.
26
- ConfigurationError = Class.new(OpenTelemetry::Error)
26
+ ConfigurationError = Class.new(OpenTelemetry::Error) # rubocop:disable Style/EmptyClassDefinition
27
27
 
28
28
  # Configures SDK and instrumentation
29
29
  #
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opentelemetry-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.12.1
4
+ version: 1.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenTelemetry Authors
@@ -125,10 +125,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby
125
125
  licenses:
126
126
  - Apache-2.0
127
127
  metadata:
128
- changelog_uri: https://rubydoc.info/gems/opentelemetry-sdk/1.12.1/file/CHANGELOG.md
129
- source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/opentelemetry-sdk/v1.12.1/sdk
128
+ changelog_uri: https://rubydoc.info/gems/opentelemetry-sdk/1.13.0/file/CHANGELOG.md
129
+ source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/opentelemetry-sdk/v1.13.0/sdk
130
130
  bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby/issues
131
- documentation_uri: https://rubydoc.info/gems/opentelemetry-sdk/1.12.1
131
+ documentation_uri: https://rubydoc.info/gems/opentelemetry-sdk/1.13.0
132
132
  rdoc_options: []
133
133
  require_paths:
134
134
  - lib
@@ -143,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
143
  - !ruby/object:Gem::Version
144
144
  version: '0'
145
145
  requirements: []
146
- rubygems_version: 4.0.10
146
+ rubygems_version: 4.0.16
147
147
  specification_version: 4
148
148
  summary: A stats collection and distributed tracing framework
149
149
  test_files: []