opentelemetry-sdk 1.4.1 → 1.5.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: 30876b5f639b980b00d48fbae72e4b01850b3c57cafa01aa4dc5ca580be0918d
4
- data.tar.gz: d002cb6584183e04b65a7b770bb75565bee3fe54396ade52714a009a26a5cb92
3
+ metadata.gz: b70cae251bf7d731f7dbdd321ab8fdd78eb9fe5dcb28cb895f6847f3698fe74b
4
+ data.tar.gz: 417ff458787750953ce76a192884ab85eece7a61a25c1b54440b10e2d5b58799
5
5
  SHA512:
6
- metadata.gz: 940facba296fde53952e694e465b7ab72cbbfabbeaa1e8bec8444476dcd57c6efd5227208021722d7130698eb33f0baf5d332594bac5f79ec946950b3c5231e3
7
- data.tar.gz: 3b2f25a049880af16792a74ec5c35b3531555bff41f049ddf91422da7896f836a295c54419fc8e82abfe076cfd6fe003a0093a2a91319e65c246c00dc280e229
6
+ metadata.gz: 0f91e38c0d21fb8da9dde9db0b7fa89f8174b974d9465e83385d6b36686796a84d84fd1171a3e7f0da1fc86bcfb3e31ccebdb0d71f5ed55b1e5e42d64f679381
7
+ data.tar.gz: 9531e30f35d34e08866a5646fdcff8a01655975fe257c9ca44a4c7713946d19c7d06be64c3b0de1e9c8e1460e084aa77032d8116cdaf0e2fdf1b73bfa1fe0326
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
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
+
3
8
  ### v1.4.1 / 2024-03-21
4
9
 
5
10
  * FIXED: ForwardingLogger should forward block param.
@@ -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.1'
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.1
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-03-26 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.1/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.1
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: