opentelemetry-sdk 1.4.0 → 1.5.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: 83a673caf48821ecaaebd3bf954cc674b720eee1727eff03b5094ecd4338971c
4
- data.tar.gz: 3fb2937947b640cc86e4ae7d56137bf4cf6683e4f11e378002a56ca8c45506d5
3
+ metadata.gz: b70cae251bf7d731f7dbdd321ab8fdd78eb9fe5dcb28cb895f6847f3698fe74b
4
+ data.tar.gz: 417ff458787750953ce76a192884ab85eece7a61a25c1b54440b10e2d5b58799
5
5
  SHA512:
6
- metadata.gz: e3f0135a67fffcb1a50c8d7a639dcd9e02a2b7d8abe61ff9beb3553a2ed1e8d93fbbe08904b46fbbebaa0c913ae6acd3a88c93329168cf00be13f205511bc48f
7
- data.tar.gz: 7197e47a5a52adabad0f651b3d7b7a9cc3f5b5f4792e64a20790efb69fc20315ab5fef322ff0798eb6e3ee6eb88e8b25429e5412657cc61fcb19496fbbe79de9
6
+ metadata.gz: 0f91e38c0d21fb8da9dde9db0b7fa89f8174b974d9465e83385d6b36686796a84d84fd1171a3e7f0da1fc86bcfb3e31ccebdb0d71f5ed55b1e5e42d64f679381
7
+ data.tar.gz: 9531e30f35d34e08866a5646fdcff8a01655975fe257c9ca44a4c7713946d19c7d06be64c3b0de1e9c8e1460e084aa77032d8116cdaf0e2fdf1b73bfa1fe0326
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Release History: opentelemetry-sdk
2
2
 
3
+ ### v1.5.0 / 2024-07-24
4
+
5
+ * ADDED: Add add_link to span api/sdk
6
+ * FIXED: Update `untraced` to suppress logging "Calling finish on an ended Span" warnings
7
+
8
+ ### v1.4.1 / 2024-03-21
9
+
10
+ * FIXED: ForwardingLogger should forward block param.
11
+
3
12
  ### v1.4.0 / 2024-01-25
4
13
 
5
14
  * ADDED: Add spans to Trace::ExportError
@@ -35,10 +35,10 @@ module OpenTelemetry
35
35
  end
36
36
  end
37
37
 
38
- def add(severity, message = nil, progname = nil)
38
+ def add(severity, message = nil, progname = nil, &block)
39
39
  return true if severity < @level
40
40
 
41
- @logger.add(severity, message, progname)
41
+ @logger.add(severity, message, progname, &block)
42
42
  end
43
43
 
44
44
  def debug(progname = nil, &block)
@@ -80,7 +80,7 @@ module OpenTelemetry
80
80
  lock do
81
81
  reset_on_fork
82
82
  n = spans.size + 1 - max_queue_size
83
- if n.positive?
83
+ if n > 0
84
84
  dropped_spans = spans.shift(n)
85
85
  report_dropped_spans(dropped_spans, reason: 'buffer-full', function: __method__.to_s)
86
86
  end
@@ -118,6 +118,37 @@ module OpenTelemetry
118
118
  self
119
119
  end
120
120
 
121
+ # Add a link to a {Span}.
122
+ #
123
+ # Adding links at span creation using the `links` option is preferred
124
+ # to calling add_link later, because head sampling decisions can only
125
+ # consider information present during span creation.
126
+ #
127
+ # Example:
128
+ #
129
+ # span.add_link(OpenTelemetry::Trace::Link.new(span_to_link_from.context))
130
+ #
131
+ # Note that the OpenTelemetry project
132
+ # {https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/data-semantic-conventions.md
133
+ # documents} certain "standard attributes" that have prescribed semantic
134
+ # meanings.
135
+ #
136
+ # @param [OpenTelemetry::Trace::Link] the link object to add on the {Span}.
137
+ #
138
+ # @return [self] returns itself
139
+ def add_link(link)
140
+ @mutex.synchronize do
141
+ if @ended
142
+ OpenTelemetry.logger.warn('Calling add_link on an ended Span.')
143
+ else
144
+ @links ||= []
145
+ @links = trim_links(@links << link, @span_limits.link_count_limit, @span_limits.link_attribute_count_limit)
146
+ @total_recorded_links += 1
147
+ end
148
+ end
149
+ self
150
+ end
151
+
121
152
  # Add an Event to a {Span}.
122
153
  #
123
154
  # Example:
@@ -242,6 +273,7 @@ module OpenTelemetry
242
273
  @end_timestamp = relative_timestamp(end_timestamp)
243
274
  @attributes = validated_attributes(@attributes).freeze
244
275
  @events.freeze
276
+ @links.freeze
245
277
  @ended = true
246
278
  end
247
279
  @span_processors.each { |processor| processor.on_finish(self) }
@@ -373,7 +405,7 @@ module OpenTelemetry
373
405
 
374
406
  if links.size <= link_count_limit &&
375
407
  links.all? { |link| link.span_context.valid? && link.attributes.size <= link_attribute_count_limit && Internal.valid_attributes?(name, 'link', link.attributes) }
376
- return links.frozen? ? links : links.clone.freeze
408
+ return links
377
409
  end
378
410
 
379
411
  # Slow path: trim attributes for each Link.
@@ -386,7 +418,7 @@ module OpenTelemetry
386
418
  excess = attrs.size - link_attribute_count_limit
387
419
  excess.times { attrs.shift } if excess.positive?
388
420
  OpenTelemetry::Trace::Link.new(link.span_context, attrs)
389
- end.freeze
421
+ end
390
422
  end
391
423
 
392
424
  def append_event(events, event) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
@@ -29,8 +29,6 @@ module OpenTelemetry
29
29
 
30
30
  def start_span(name, with_parent: nil, attributes: nil, links: nil, start_timestamp: nil, kind: nil)
31
31
  with_parent ||= Context.current
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
32
  name ||= 'empty'
35
33
  kind ||= :internal
36
34
 
@@ -126,7 +126,7 @@ module OpenTelemetry
126
126
  end
127
127
 
128
128
  # @api private
129
- def internal_start_span(name, kind, attributes, links, start_timestamp, parent_context, instrumentation_scope) # rubocop:disable Metrics/MethodLength
129
+ def internal_start_span(name, kind, attributes, links, start_timestamp, parent_context, instrumentation_scope) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
130
130
  parent_span = OpenTelemetry::Trace.current_span(parent_context)
131
131
  parent_span_context = parent_span.context
132
132
 
@@ -134,8 +134,13 @@ module OpenTelemetry
134
134
  parent_span_id = parent_span_context.span_id
135
135
  trace_id = parent_span_context.trace_id
136
136
  end
137
-
138
137
  trace_id ||= @id_generator.generate_trace_id
138
+
139
+ if OpenTelemetry::Common::Utilities.untraced?(parent_context)
140
+ span_id = parent_span_id || @id_generator.generate_span_id
141
+ return OpenTelemetry::Trace.non_recording_span(OpenTelemetry::Trace::SpanContext.new(trace_id: trace_id, span_id: span_id))
142
+ end
143
+
139
144
  result = @sampler.should_sample?(trace_id: trace_id, parent_context: parent_context, links: links, name: name, kind: kind, attributes: attributes)
140
145
  span_id = @id_generator.generate_span_id
141
146
  if result.recording? && !@stopped
@@ -7,6 +7,6 @@
7
7
  module OpenTelemetry
8
8
  module SDK
9
9
  ## Current OpenTelemetry version
10
- VERSION = '1.4.0'
10
+ VERSION = '1.5.0'
11
11
  end
12
12
  end
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.4.0
4
+ version: 1.5.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-01-25 00:00:00.000000000 Z
11
+ date: 2024-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opentelemetry-api
@@ -294,10 +294,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby
294
294
  licenses:
295
295
  - Apache-2.0
296
296
  metadata:
297
- changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk/v1.4.0/file.CHANGELOG.html
297
+ changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk/v1.5.0/file.CHANGELOG.html
298
298
  source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/sdk
299
299
  bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby/issues
300
- documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk/v1.4.0
300
+ documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk/v1.5.0
301
301
  post_install_message:
302
302
  rdoc_options: []
303
303
  require_paths: