opentelemetry-sdk 1.1.0 → 1.2.1

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: d222b778e1876c24a4bf0f71f30ec32ff23b75b28eaf6d436d2341123a044f31
4
- data.tar.gz: 8d2eb94080371ad6bdcef6c14dbe0dd8cbc9355c1d395b7fe675cd64ed02f667
3
+ metadata.gz: 8b3929809dfb23b087387864352e6fdb690fc24b99cfd3e236f710b8b5b01eb4
4
+ data.tar.gz: 11630ddd0ead48711a68b534de8e75d05395d9d9d2f43177d6c2465b17ff7f2a
5
5
  SHA512:
6
- metadata.gz: 1f03bfb89f173d1c9a88f9027ca0c2bf29353330bf640ba3aeba8b68167e8c0d9a5d4d1aa6b50dfa728e5e3a90a64e25c5597e72e628bc918726f7dafbc15bea
7
- data.tar.gz: 784998cd384e404a2b3f312fc5560482cfc2ddd942ea2e57216320898b33399f9e554f16de50af5987a60a9c3ddbd4b9847259ab42abfe76d8e4a50cf07c6367
6
+ metadata.gz: 7756b25f8fd77c81dfd3d824fee54dd4a74c1afb1ca6c47a345ad02b2fd58de0654a7a21680a3ade0d70b3e77ca1006c4b3d36a361e6e5e59507b037d9041274
7
+ data.tar.gz: cac44fe7f43d2ef5309de35eb3af9a4420bbe6f9ee49ca1ab2ba59d2a539699ed6712277b265ca5225290c648ea07a9a82cd44aa4ec537af0b951ea01764d5f5
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Release History: opentelemetry-sdk
2
2
 
3
+ ### v1.2.1 / 2023-05-30
4
+
5
+ * FIXED: Untraced only works with parent-based sampler
6
+ * DOCS: Improve formatting of usage examples in OpenTelemetry SDK rubydocs
7
+
8
+ ### v1.2.0 / 2022-09-14
9
+
10
+ * ADDED: Support OTEL_PROPAGATORS=none
11
+ * ADDED: Support OTEL_ATTRIBUTE_{COUNT,VALUE_LENGTH}_LIMIT env vars
12
+ * ADDED: Support InstrumentationScope, and update OTLP proto to 0.18.0
13
+ * FIXED: SpanLimits setting event attributes length limit
14
+
3
15
  ### v1.1.0 / 2022-05-26
4
16
 
5
17
  * BREAKING CHANGE: This requires upgrading both the SDK and Instrumentation gem in tandem
@@ -141,11 +141,14 @@ module OpenTelemetry
141
141
  configure_span_processors
142
142
  tracer_provider.id_generator = @id_generator
143
143
  OpenTelemetry.tracer_provider = tracer_provider
144
+ metrics_configuration_hook
144
145
  install_instrumentation
145
146
  end
146
147
 
147
148
  private
148
149
 
150
+ def metrics_configuration_hook; end
151
+
149
152
  def tracer_provider
150
153
  @tracer_provider ||= Trace::TracerProvider.new(resource: @resource)
151
154
  end
@@ -169,7 +172,7 @@ module OpenTelemetry
169
172
  processors.each { |p| tracer_provider.add_span_processor(p) }
170
173
  end
171
174
 
172
- def wrapped_exporters_from_env # rubocop:disable Metrics/CyclomaticComplexity, Metrics/AbcSize
175
+ def wrapped_exporters_from_env # rubocop:disable Metrics/CyclomaticComplexity
173
176
  exporters = ENV.fetch('OTEL_TRACES_EXPORTER', 'otlp')
174
177
  exporters.split(',').map do |exporter|
175
178
  case exporter.strip
@@ -203,6 +206,7 @@ module OpenTelemetry
203
206
  when 'jaeger' then fetch_propagator(propagator, 'OpenTelemetry::Propagator::Jaeger')
204
207
  when 'xray' then fetch_propagator(propagator, 'OpenTelemetry::Propagator::XRay')
205
208
  when 'ottrace' then fetch_propagator(propagator, 'OpenTelemetry::Propagator::OTTrace')
209
+ when 'none' then NoopTextMapPropagator.new
206
210
  else
207
211
  OpenTelemetry.logger.warn "The #{propagator} propagator is unknown and cannot be configured"
208
212
  NoopTextMapPropagator.new
@@ -10,7 +10,7 @@ module OpenTelemetry
10
10
  # with an ERROR log level, only OpenTelemetry logs at the ERROR level or higher
11
11
  # will be emitted.
12
12
  class ForwardingLogger
13
- def initialize(logger, level:) # rubocop:disable Metrics/CyclomaticComplexity
13
+ def initialize(logger, level:)
14
14
  @logger = logger
15
15
 
16
16
  if level.is_a?(Integer)
@@ -7,6 +7,7 @@
7
7
  module OpenTelemetry
8
8
  module SDK
9
9
  # InstrumentationLibrary is a struct containing library information for export.
10
+ # @deprecated Use InstrumentationScope instead.
10
11
  InstrumentationLibrary = Struct.new(:name,
11
12
  :version)
12
13
  end
@@ -0,0 +1,13 @@
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
+ # InstrumentationScope is a struct containing scope information for export.
10
+ InstrumentationScope = Struct.new(:name,
11
+ :version)
12
+ end
13
+ end
@@ -11,7 +11,7 @@ module OpenTelemetry
11
11
  # for which telemetry (metrics or traces) is reported.
12
12
  class Resource
13
13
  class << self
14
- private :new # rubocop:disable Style/AccessModifierDeclarations
14
+ private :new
15
15
 
16
16
  # Returns a newly created {Resource} with the specified attributes
17
17
  #
@@ -30,10 +30,10 @@ module OpenTelemetry
30
30
  #
31
31
  # @param [SpanExporter] exporter the (duck type) SpanExporter to where the
32
32
  # recorded Spans are pushed after batching.
33
- # @param [Numeric] exporter_timeout the delay interval between two
34
- # consecutive exports. Defaults to the value of the OTEL_BSP_EXPORT_TIMEOUT
33
+ # @param [Numeric] exporter_timeout the maximum allowed time to export data.
34
+ # Defaults to the value of the OTEL_BSP_EXPORT_TIMEOUT
35
35
  # environment variable, if set, or 30,000 (30 seconds).
36
- # @param [Numeric] schedule_delay the maximum allowed time to export data.
36
+ # @param [Numeric] schedule_delay the delay interval between two consecutive exports.
37
37
  # Defaults to the value of the OTEL_BSP_SCHEDULE_DELAY environment
38
38
  # variable, if set, or 5,000 (5 seconds).
39
39
  # @param [Integer] max_queue_size the maximum queue size in spans.
@@ -74,7 +74,7 @@ module OpenTelemetry
74
74
  def on_start(_span, _parent_context); end
75
75
 
76
76
  # Adds a span to the batch. Thread-safe; may block on lock.
77
- def on_finish(span) # rubocop:disable Metrics/AbcSize
77
+ def on_finish(span)
78
78
  return unless span.context.trace_flags.sampled?
79
79
 
80
80
  lock do
@@ -100,7 +100,7 @@ module OpenTelemetry
100
100
  # @param [optional Numeric] timeout An optional timeout in seconds.
101
101
  # @return [Integer] SUCCESS if no error occurred, FAILURE if a
102
102
  # non-specific failure occurred, TIMEOUT if a timeout occurred.
103
- def force_flush(timeout: nil) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength
103
+ def force_flush(timeout: nil) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength
104
104
  start_time = OpenTelemetry::Common::Utilities.timeout_timestamp
105
105
  snapshot = lock do
106
106
  reset_on_fork if @keep_running
@@ -155,7 +155,7 @@ module OpenTelemetry
155
155
 
156
156
  attr_reader :spans, :max_queue_size, :batch_size
157
157
 
158
- def work # rubocop:disable Metrics/AbcSize
158
+ def work
159
159
  loop do
160
160
  batch = lock do
161
161
  @condition.wait(@mutex, @delay_seconds) if spans.size < batch_size && @keep_running
@@ -4,8 +4,6 @@
4
4
  #
5
5
  # SPDX-License-Identifier: Apache-2.0
6
6
 
7
- require 'pp'
8
-
9
7
  module OpenTelemetry
10
8
  module SDK
11
9
  module Trace
@@ -10,26 +10,26 @@ module OpenTelemetry
10
10
  module Export
11
11
  # A SpanExporter implementation that can be used to test OpenTelemetry integration.
12
12
  #
13
- # Example usage in a test suite:
13
+ # @example Usage in a test suite:
14
+ # class MyClassTest
15
+ # def setup
16
+ # @tracer_provider = TracerProvider.new
17
+ # # The default is `recording: true`, which is appropriate in non-test environments.
18
+ # @exporter = InMemorySpanExporter.new(recording: false)
19
+ # @tracer_provider.add_span_processor(SimpleSampledSpansProcessor.new(@exporter))
20
+ # end
14
21
  #
15
- # class MyClassTest
16
- # def setup
17
- # @tracer_provider = TracerProvider.new
18
- # # The default is `recording: true`, which is appropriate in non-test environments.
19
- # @exporter = InMemorySpanExporter.new(recording: false)
20
- # @tracer_provider.add_span_processor(SimpleSampledSpansProcessor.new(@exporter))
21
- # end
22
- #
23
- # def test_finished_spans
24
- # @exporter.recording = true
25
- # @tracer_provider.tracer.in_span("span") {}
22
+ # def test_finished_spans
23
+ # @exporter.recording = true
24
+ # @tracer_provider.tracer.in_span("span") {}
26
25
  #
27
- # spans = @exporter.finished_spans
28
- # spans.wont_be_nil
29
- # spans.size.must_equal(1)
30
- # spans[0].name.must_equal("span")
26
+ # spans = @exporter.finished_spans
27
+ # spans.wont_be_nil
28
+ # spans.size.must_equal(1)
29
+ # spans[0].name.must_equal("span")
31
30
  #
32
- # @exporter.recording = false
31
+ # @exporter.recording = false
32
+ # end
33
33
  # end
34
34
  class InMemorySpanExporter
35
35
  # Controls whether or not the exporter will record spans, or discard them.
@@ -15,6 +15,7 @@ module OpenTelemetry
15
15
  # the unstable OpenTelemetry Metrics API. An example implementation in
16
16
  # terms of StatsD is:
17
17
  #
18
+ # @example
18
19
  # module MetricsReporter
19
20
  # def add_to_counter(metric, increment: 1, labels: {})
20
21
  # StatsD.increment(metric, increment, labels, no_prefix: true)
@@ -40,7 +40,7 @@ module OpenTelemetry
40
40
  # an empty Tracestate here, the Tracestate will be cleared, so
41
41
  # samplers SHOULD normally return the passed-in Tracestate if they
42
42
  # do not intend to change it.
43
- def initialize(decision:, attributes: nil, tracestate:)
43
+ def initialize(decision:, tracestate:, attributes: nil)
44
44
  @decision = decision
45
45
  @attributes = attributes.freeze || EMPTY_HASH
46
46
  @tracestate = tracestate
@@ -23,7 +23,13 @@ module OpenTelemetry
23
23
 
24
24
  # The following readers are intended for the use of SpanProcessors and
25
25
  # should not be considered part of the public interface for instrumentation.
26
- attr_reader :name, :status, :kind, :parent_span_id, :start_timestamp, :end_timestamp, :links, :resource, :instrumentation_library
26
+ attr_reader :name, :status, :kind, :parent_span_id, :start_timestamp, :end_timestamp, :links, :resource, :instrumentation_scope
27
+
28
+ # Returns an InstrumentationScope struct, which is backwards compatible with InstrumentationLibrary.
29
+ # @deprecated Please use instrumentation_scope instead.
30
+ #
31
+ # @return InstrumentationScope
32
+ alias instrumentation_library instrumentation_scope
27
33
 
28
34
  # Return a frozen copy of the current attributes. This is intended for
29
35
  # use of SpanProcessors and should not be considered part of the public
@@ -131,7 +137,7 @@ module OpenTelemetry
131
137
  #
132
138
  # @return [self] returns itself
133
139
  def add_event(name, attributes: nil, timestamp: nil)
134
- event = Event.new(name, truncate_attribute_values(attributes), relative_timestamp(timestamp))
140
+ event = Event.new(name, truncate_attribute_values(attributes, @span_limits.event_attribute_length_limit), relative_timestamp(timestamp))
135
141
 
136
142
  @mutex.synchronize do
137
143
  if @ended
@@ -267,7 +273,7 @@ module OpenTelemetry
267
273
  @links,
268
274
  @events,
269
275
  @resource,
270
- @instrumentation_library,
276
+ @instrumentation_scope,
271
277
  context.span_id,
272
278
  context.trace_id,
273
279
  context.trace_flags,
@@ -276,7 +282,7 @@ module OpenTelemetry
276
282
  end
277
283
 
278
284
  # @api private
279
- def initialize(context, parent_context, parent_span, name, kind, parent_span_id, span_limits, span_processors, attributes, links, start_timestamp, resource, instrumentation_library) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
285
+ def initialize(context, parent_context, parent_span, name, kind, parent_span_id, span_limits, span_processors, attributes, links, start_timestamp, resource, instrumentation_scope) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
280
286
  super(span_context: context)
281
287
  @mutex = Mutex.new
282
288
  @name = name
@@ -285,7 +291,7 @@ module OpenTelemetry
285
291
  @span_limits = span_limits
286
292
  @span_processors = span_processors
287
293
  @resource = resource
288
- @instrumentation_library = instrumentation_library
294
+ @instrumentation_scope = instrumentation_scope
289
295
  @ended = false
290
296
  @status = DEFAULT_STATUS
291
297
  @total_recorded_events = 0
@@ -343,21 +349,19 @@ module OpenTelemetry
343
349
 
344
350
  excess = attrs.size - @span_limits.attribute_count_limit
345
351
  excess.times { attrs.shift } if excess.positive?
346
- truncate_attribute_values(attrs)
352
+ truncate_attribute_values(attrs, @span_limits.attribute_length_limit)
347
353
  nil
348
354
  end
349
355
 
350
- def truncate_attribute_values(attrs)
356
+ def truncate_attribute_values(attrs, attribute_length_limit)
351
357
  return EMPTY_ATTRIBUTES if attrs.nil?
352
-
353
- attribute_length_limit = @span_limits.attribute_length_limit
354
358
  return attrs if attribute_length_limit.nil?
355
359
 
356
360
  attrs.transform_values! { |value| OpenTelemetry::Common::Utilities.truncate_attribute_value(value, attribute_length_limit) }
357
361
  attrs
358
362
  end
359
363
 
360
- def trim_links(links, link_count_limit, link_attribute_count_limit) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
364
+ def trim_links(links, link_count_limit, link_attribute_count_limit) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
361
365
  # Fast path (likely) common cases.
362
366
  return nil if links.nil?
363
367
 
@@ -379,7 +383,7 @@ module OpenTelemetry
379
383
  end.freeze
380
384
  end
381
385
 
382
- def append_event(events, event) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
386
+ def append_event(events, event) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
383
387
  event_count_limit = @span_limits.event_count_limit
384
388
  event_attribute_count_limit = @span_limits.event_attribute_count_limit
385
389
  valid_attributes = Internal.valid_attributes?(name, 'event', event.attributes)
@@ -23,7 +23,7 @@ module OpenTelemetry
23
23
  :links, # optional Array[OpenTelemetry::Trace::Link]
24
24
  :events, # optional Array[Event]
25
25
  :resource, # OpenTelemetry::SDK::Resources::Resource
26
- :instrumentation_library, # OpenTelemetry::SDK::InstrumentationLibrary
26
+ :instrumentation_scope, # OpenTelemetry::SDK::InstrumentationScope
27
27
  :span_id, # String (8 byte binary)
28
28
  :trace_id, # String (16-byte binary)
29
29
  :trace_flags, # Integer (8-bit byte of bit flags)
@@ -48,6 +48,12 @@ module OpenTelemetry
48
48
  def hex_parent_span_id
49
49
  parent_span_id.unpack1('H*')
50
50
  end
51
+
52
+ # Returns an InstrumentationScope struct, which is backwards compatible with InstrumentationLibrary.
53
+ # @deprecated Please use instrumentation_scope instead.
54
+ #
55
+ # @return InstrumentationScope
56
+ alias_method :instrumentation_library, :instrumentation_scope
51
57
  end
52
58
  end
53
59
  end
@@ -24,6 +24,9 @@ module OpenTelemetry
24
24
  # The global default max number of attributes per {OpenTelemetry::SDK::Trace::Event}.
25
25
  attr_reader :event_attribute_count_limit
26
26
 
27
+ # The global default max length of attribute value per {OpenTelemetry::SDK::Trace::Event}.
28
+ attr_reader :event_attribute_length_limit
29
+
27
30
  # The global default max number of attributes per {OpenTelemetry::Trace::Link}.
28
31
  attr_reader :link_attribute_count_limit
29
32
 
@@ -31,18 +34,20 @@ module OpenTelemetry
31
34
  #
32
35
  # @return [SpanLimits] with the desired values.
33
36
  # @raise [ArgumentError] if any of the max numbers are not positive.
34
- def initialize(attribute_count_limit: Integer(ENV.fetch('OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT', 128)), # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
35
- attribute_length_limit: ENV.fetch('OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT',
36
- ENV['OTEL_RUBY_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT']),
37
- event_count_limit: Integer(ENV.fetch('OTEL_SPAN_EVENT_COUNT_LIMIT', 128)),
38
- link_count_limit: Integer(ENV.fetch('OTEL_SPAN_LINK_COUNT_LIMIT', 128)),
39
- event_attribute_count_limit: Integer(ENV.fetch('OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT', 128)),
40
- link_attribute_count_limit: Integer(ENV.fetch('OTEL_LINK_ATTRIBUTE_COUNT_LIMIT', 128)))
37
+ def initialize(attribute_count_limit: Integer(OpenTelemetry::Common::Utilities.config_opt('OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT', 'OTEL_ATTRIBUTE_COUNT_LIMIT', default: 128)), # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
38
+ attribute_length_limit: OpenTelemetry::Common::Utilities.config_opt('OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT', 'OTEL_RUBY_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT', 'OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT'),
39
+ event_count_limit: Integer(OpenTelemetry::Common::Utilities.config_opt('OTEL_SPAN_EVENT_COUNT_LIMIT', default: 128)),
40
+ link_count_limit: Integer(OpenTelemetry::Common::Utilities.config_opt('OTEL_SPAN_LINK_COUNT_LIMIT', default: 128)),
41
+ event_attribute_count_limit: Integer(OpenTelemetry::Common::Utilities.config_opt('OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT', default: 128)),
42
+ event_attribute_length_limit: OpenTelemetry::Common::Utilities.config_opt('OTEL_EVENT_ATTRIBUTE_VALUE_LENGTH_LIMIT', 'OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT'),
43
+ link_attribute_count_limit: Integer(OpenTelemetry::Common::Utilities.config_opt('OTEL_LINK_ATTRIBUTE_COUNT_LIMIT', default: 128)))
44
+
41
45
  raise ArgumentError, 'attribute_count_limit must be positive' unless attribute_count_limit.positive?
42
46
  raise ArgumentError, 'attribute_length_limit must not be less than 32' unless attribute_length_limit.nil? || Integer(attribute_length_limit) >= 32
43
47
  raise ArgumentError, 'event_count_limit must be positive' unless event_count_limit.positive?
44
48
  raise ArgumentError, 'link_count_limit must be positive' unless link_count_limit.positive?
45
49
  raise ArgumentError, 'event_attribute_count_limit must be positive' unless event_attribute_count_limit.positive?
50
+ raise ArgumentError, 'event_attribute_length_limit must not be less than 32' unless event_attribute_length_limit.nil? || Integer(event_attribute_length_limit) >= 32
46
51
  raise ArgumentError, 'link_attribute_count_limit must be positive' unless link_attribute_count_limit.positive?
47
52
 
48
53
  @attribute_count_limit = attribute_count_limit
@@ -50,6 +55,7 @@ module OpenTelemetry
50
55
  @event_count_limit = event_count_limit
51
56
  @link_count_limit = link_count_limit
52
57
  @event_attribute_count_limit = event_attribute_count_limit
58
+ @event_attribute_length_limit = event_attribute_length_limit.nil? ? nil : Integer(event_attribute_length_limit)
53
59
  @link_attribute_count_limit = link_attribute_count_limit
54
60
  end
55
61
 
@@ -19,7 +19,7 @@ module OpenTelemetry
19
19
  #
20
20
  # @return [Tracer]
21
21
  def initialize(name, version, tracer_provider)
22
- @instrumentation_library = InstrumentationLibrary.new(name, version)
22
+ @instrumentation_scope = InstrumentationScope.new(name, version)
23
23
  @tracer_provider = tracer_provider
24
24
  end
25
25
 
@@ -28,17 +28,13 @@ module OpenTelemetry
28
28
  end
29
29
 
30
30
  def start_span(name, with_parent: nil, attributes: nil, links: nil, start_timestamp: nil, kind: nil)
31
- name ||= 'empty'
32
-
33
31
  with_parent ||= Context.current
34
- parent_span = OpenTelemetry::Trace.current_span(with_parent)
35
- parent_span_context = OpenTelemetry::Trace.current_span(with_parent).context
36
- if parent_span_context.valid?
37
- parent_span_id = parent_span_context.span_id
38
- trace_id = parent_span_context.trace_id
39
- end
32
+ return super(name, with_parent: with_parent, attributes: attributes, links: links, start_timestamp: start_timestamp, kind: kind) if Common::Utilities.untraced?(with_parent)
33
+
34
+ name ||= 'empty'
35
+ kind ||= :internal
40
36
 
41
- @tracer_provider.internal_create_span(name, kind, trace_id, parent_span_id, attributes, links, start_timestamp, with_parent, parent_span, @instrumentation_library)
37
+ @tracer_provider.internal_start_span(name, kind, attributes, links, start_timestamp, with_parent, @instrumentation_scope)
42
38
  end
43
39
  end
44
40
  end
@@ -126,15 +126,16 @@ module OpenTelemetry
126
126
  end
127
127
 
128
128
  # @api private
129
- def internal_create_span(name, kind, trace_id, parent_span_id, attributes, links, start_timestamp, parent_context, parent_span, instrumentation_library) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
129
+ def internal_start_span(name, kind, attributes, links, start_timestamp, parent_context, instrumentation_scope) # rubocop:disable Metrics/MethodLength
130
+ parent_span = OpenTelemetry::Trace.current_span(parent_context)
130
131
  parent_span_context = parent_span.context
132
+
131
133
  if parent_span_context.valid?
132
134
  parent_span_id = parent_span_context.span_id
133
135
  trace_id = parent_span_context.trace_id
134
136
  end
135
- name ||= 'empty'
137
+
136
138
  trace_id ||= @id_generator.generate_trace_id
137
- kind ||= :internal
138
139
  result = @sampler.should_sample?(trace_id: trace_id, parent_context: parent_context, links: links, name: name, kind: kind, attributes: attributes)
139
140
  span_id = @id_generator.generate_span_id
140
141
  if result.recording? && !@stopped
@@ -154,7 +155,7 @@ module OpenTelemetry
154
155
  links,
155
156
  start_timestamp,
156
157
  @resource,
157
- instrumentation_library
158
+ instrumentation_scope
158
159
  )
159
160
  else
160
161
  OpenTelemetry::Trace.non_recording_span(OpenTelemetry::Trace::SpanContext.new(trace_id: trace_id, span_id: span_id, tracestate: result.tracestate))
@@ -163,7 +164,7 @@ module OpenTelemetry
163
164
 
164
165
  private
165
166
 
166
- def sampler_from_environment(default_sampler) # rubocop:disable Metrics/CyclomaticComplexity
167
+ def sampler_from_environment(default_sampler)
167
168
  case ENV['OTEL_TRACES_SAMPLER']
168
169
  when 'always_on' then Samplers::ALWAYS_ON
169
170
  when 'always_off' then Samplers::ALWAYS_OFF
@@ -7,6 +7,6 @@
7
7
  module OpenTelemetry
8
8
  module SDK
9
9
  ## Current OpenTelemetry version
10
- VERSION = '1.1.0'
10
+ VERSION = '1.2.1'
11
11
  end
12
12
  end
@@ -78,6 +78,7 @@ require 'opentelemetry/sdk/configurator'
78
78
  require 'opentelemetry/sdk/forwarding_logger'
79
79
  require 'opentelemetry/sdk/internal'
80
80
  require 'opentelemetry/sdk/instrumentation_library'
81
+ require 'opentelemetry/sdk/instrumentation_scope'
81
82
  require 'opentelemetry/sdk/resources'
82
83
  require 'opentelemetry/sdk/trace'
83
84
  require 'opentelemetry/sdk/version'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opentelemetry-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.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: 2022-05-26 00:00:00.000000000 Z
11
+ date: 2023-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opentelemetry-api
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.0'
19
+ version: '1.1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.0'
26
+ version: '1.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: opentelemetry-common
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0.1'
47
+ version: '0.2'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0.1'
54
+ version: '0.2'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: opentelemetry-semantic_conventions
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '5.0'
103
+ version: 5.15.0
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '5.0'
110
+ version: 5.15.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: opentelemetry-exporter-zipkin
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -184,14 +184,14 @@ dependencies:
184
184
  requirements:
185
185
  - - "~>"
186
186
  - !ruby/object:Gem::Version
187
- version: 0.73.0
187
+ version: 1.51.0
188
188
  type: :development
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
192
  - - "~>"
193
193
  - !ruby/object:Gem::Version
194
- version: 0.73.0
194
+ version: 1.51.0
195
195
  - !ruby/object:Gem::Dependency
196
196
  name: simplecov
197
197
  requirement: !ruby/object:Gem::Requirement
@@ -264,6 +264,7 @@ files:
264
264
  - lib/opentelemetry/sdk/configurator.rb
265
265
  - lib/opentelemetry/sdk/forwarding_logger.rb
266
266
  - lib/opentelemetry/sdk/instrumentation_library.rb
267
+ - lib/opentelemetry/sdk/instrumentation_scope.rb
267
268
  - lib/opentelemetry/sdk/internal.rb
268
269
  - lib/opentelemetry/sdk/resources.rb
269
270
  - lib/opentelemetry/sdk/resources/resource.rb
@@ -293,10 +294,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby
293
294
  licenses:
294
295
  - Apache-2.0
295
296
  metadata:
296
- changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk/v1.1.0/file.CHANGELOG.html
297
+ changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk/v1.2.1/file.CHANGELOG.html
297
298
  source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/sdk
298
299
  bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby/issues
299
- documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk/v1.1.0
300
+ documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk/v1.2.1
300
301
  post_install_message:
301
302
  rdoc_options: []
302
303
  require_paths: