opentelemetry-sdk 1.3.0 → 1.3.2

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: 7cb2a536d6bf68847feac7a09754a427cf7b17ef3e84bbffa46048f90cd6577e
4
- data.tar.gz: 7b48fd5ecadc6f229b0a32672b280ed6ea924a5e3bf0cd20631694c0bf8ebef0
3
+ metadata.gz: ef291be552aa487d0348eeadee291923710eb8621f74b552d41835f480056869
4
+ data.tar.gz: 84ccd40e5b33a3a7a4c0c90b265e87708f3f42ba843166b39d2282aa5eb2382a
5
5
  SHA512:
6
- metadata.gz: 7fe7fe35fbe00ea7e0370b2b9684800eeae0d13d71c10a28040b3a10f82c63422b4986dbf33164e83b97ed90723cf9d8eff1c75b693c854fab3a9a1f05f59846
7
- data.tar.gz: 68795672a61c8a9118507ad0a6cd9b5fa52be71eb06021e2f53e9fc3a490330e1a8c844fd51868b5e413db356f668a8cb32e9a311f36fd51b0e3cb6211111a83
6
+ metadata.gz: 43c4598b75aaeea2c46e89c72db0bc10b2a78a9a9d553c3bf777d65dc0b80a8cdab4d3c0c52f05fa9fdf691a4e3e8e8cb5e808c4d762fdca7cfa0832ee6dd1a1
7
+ data.tar.gz: c4e434f89f6a8ee8207b8036e31147db0ea9bf4931bb6130db120c6b6a0b78a93ca32e17bf1316a1b56f6162724335716cfaaf34b6b046a1df28be22de4b9653
data/CHANGELOG.md CHANGED
@@ -1,41 +1,51 @@
1
1
  # Release History: opentelemetry-sdk
2
2
 
3
+ ### v1.3.2 / 2024-01-23
4
+
5
+ * FIXED: Reduce allocations on GraphQL hot paths
6
+ * FIXED: Add context to metrics reporting of buffer-full events
7
+
8
+ ### v1.3.1 / 2023-11-02
9
+
10
+ * FIXED: Spec compliance for span attribute limit
11
+ * FIXED: BatchSpanProcessor#force_flush: purge inherited spans even on shutdown
12
+
3
13
  ### v1.3.0 / 2023-06-08
4
14
 
5
- * BREAKING CHANGE: Remove support for EoL Ruby 2.7
15
+ * BREAKING CHANGE: Remove support for EoL Ruby 2.7
6
16
 
7
- * ADDED: Remove support for EoL Ruby 2.7
8
- * FIXED: SDK requires opentelemetry-common 0.19.7
17
+ * ADDED: Remove support for EoL Ruby 2.7
18
+ * FIXED: SDK requires opentelemetry-common 0.19.7
9
19
 
10
20
  ### v1.2.1 / 2023-05-30
11
21
 
12
- * FIXED: Untraced only works with parent-based sampler
13
- * DOCS: Improve formatting of usage examples in OpenTelemetry SDK rubydocs
22
+ * FIXED: Untraced only works with parent-based sampler
23
+ * DOCS: Improve formatting of usage examples in OpenTelemetry SDK rubydocs
14
24
 
15
25
  ### v1.2.0 / 2022-09-14
16
26
 
17
- * ADDED: Support OTEL_PROPAGATORS=none
18
- * ADDED: Support OTEL_ATTRIBUTE_{COUNT,VALUE_LENGTH}_LIMIT env vars
19
- * ADDED: Support InstrumentationScope, and update OTLP proto to 0.18.0
20
- * FIXED: SpanLimits setting event attributes length limit
27
+ * ADDED: Support OTEL_PROPAGATORS=none
28
+ * ADDED: Support OTEL_ATTRIBUTE_{COUNT,VALUE_LENGTH}_LIMIT env vars
29
+ * ADDED: Support InstrumentationScope, and update OTLP proto to 0.18.0
30
+ * FIXED: SpanLimits setting event attributes length limit
21
31
 
22
32
  ### v1.1.0 / 2022-05-26
23
33
 
24
- * BREAKING CHANGE: This requires upgrading both the SDK and Instrumentation gem in tandem
34
+ * BREAKING CHANGE: This requires upgrading both the SDK and Instrumentation gem in tandem
25
35
 
26
36
 
27
37
  ### v1.0.3 / 2022-05-02
28
38
 
29
39
  * ADDED: Truncate the strings in an array attribute value if length_limit is configured
30
- * FIXED: Update attribute length limit env var name to match spec
31
- * FIXED: Warning about Struct initialization in Ruby 3.2+
32
- * FIXED: Warn on unsupported otlp transport protocols
33
- * FIXED: Only allow certain types of Numeric values as attribute values.
40
+ * FIXED: Update attribute length limit env var name to match spec
41
+ * FIXED: Warning about Struct initialization in Ruby 3.2+
42
+ * FIXED: Warn on unsupported otlp transport protocols
43
+ * FIXED: Only allow certain types of Numeric values as attribute values.
34
44
 
35
45
  ### v1.0.2 / 2021-12-01
36
46
 
37
- * FIXED: Default span kind
38
- * FIXED: Use monotonic clock where possible
47
+ * FIXED: Default span kind
48
+ * FIXED: Use monotonic clock where possible
39
49
 
40
50
  ### v1.0.1 / 2021-10-29
41
51
 
@@ -49,17 +49,17 @@ module OpenTelemetry
49
49
  end
50
50
 
51
51
  def valid_attributes?(owner, kind, attrs)
52
- attrs.nil? || attrs.all? do |k, v|
52
+ attrs.nil? || attrs.each do |k, v|
53
53
  if !valid_key?(k)
54
54
  OpenTelemetry.handle_error(message: "invalid #{kind} attribute key type #{k.class} on span '#{owner}'")
55
- false
55
+ return false
56
56
  elsif !valid_value?(v)
57
57
  OpenTelemetry.handle_error(message: "invalid #{kind} attribute value type #{v.class} for key '#{k}' on span '#{owner}'")
58
- false
59
- else
60
- true
58
+ return false
61
59
  end
62
60
  end
61
+
62
+ true
63
63
  end
64
64
  end
65
65
  end
@@ -81,8 +81,8 @@ module OpenTelemetry
81
81
  reset_on_fork
82
82
  n = spans.size + 1 - max_queue_size
83
83
  if n.positive?
84
- spans.shift(n)
85
- report_dropped_spans(n, reason: 'buffer-full')
84
+ dropped_spans = spans.shift(n)
85
+ report_dropped_spans(dropped_spans, reason: 'buffer-full', function: __method__.to_s)
86
86
  end
87
87
  spans << span
88
88
  @condition.signal if spans.size > batch_size
@@ -100,10 +100,10 @@ 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/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength
103
+ def force_flush(timeout: nil) # rubocop:disable Metrics/MethodLength
104
104
  start_time = OpenTelemetry::Common::Utilities.timeout_timestamp
105
105
  snapshot = lock do
106
- reset_on_fork if @keep_running
106
+ reset_on_fork(restart_thread: @keep_running)
107
107
  spans.shift(spans.size)
108
108
  end
109
109
  until snapshot.empty?
@@ -122,8 +122,8 @@ module OpenTelemetry
122
122
  lock do
123
123
  n = spans.size + snapshot.size - max_queue_size
124
124
  if n.positive?
125
- snapshot.shift(n)
126
- report_dropped_spans(n, reason: 'buffer-full')
125
+ dropped_spans = snapshot.shift(n)
126
+ report_dropped_spans(dropped_spans, reason: 'buffer-full', function: __method__.to_s)
127
127
  end
128
128
  spans.unshift(snapshot) unless snapshot.empty?
129
129
  @condition.signal if spans.size > max_queue_size / 2
@@ -146,8 +146,8 @@ module OpenTelemetry
146
146
 
147
147
  thread&.join(timeout)
148
148
  force_flush(timeout: OpenTelemetry::Common::Utilities.maybe_timeout(timeout, start_time))
149
- dropped_spans = lock { spans.size }
150
- report_dropped_spans(dropped_spans, reason: 'terminating') if dropped_spans.positive?
149
+ dropped_spans = lock { spans.shift(spans.length) }
150
+ report_dropped_spans(dropped_spans, reason: 'terminating') if dropped_spans.any?
151
151
  @exporter.shutdown(timeout: OpenTelemetry::Common::Utilities.maybe_timeout(timeout, start_time))
152
152
  end
153
153
 
@@ -200,12 +200,12 @@ module OpenTelemetry
200
200
  else
201
201
  OpenTelemetry.handle_error(exception: ExportError.new("Unable to export #{batch.size} spans"))
202
202
  @metrics_reporter.add_to_counter('otel.bsp.export.failure')
203
- report_dropped_spans(batch.size, reason: 'export-failure')
203
+ report_dropped_spans(batch, reason: 'export-failure')
204
204
  end
205
205
  end
206
206
 
207
- def report_dropped_spans(count, reason:)
208
- @metrics_reporter.add_to_counter('otel.bsp.dropped_spans', increment: count, labels: { 'reason' => reason })
207
+ def report_dropped_spans(dropped_spans, reason:, function: nil)
208
+ @metrics_reporter.add_to_counter('otel.bsp.dropped_spans', increment: dropped_spans.size, labels: { 'reason' => reason, OpenTelemetry::SemanticConventions::Trace::CODE_FUNCTION => function }.compact)
209
209
  end
210
210
 
211
211
  def fetch_batch
@@ -282,7 +282,7 @@ module OpenTelemetry
282
282
  end
283
283
 
284
284
  # @api private
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
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/MethodLength, Metrics/PerceivedComplexity
286
286
  super(span_context: context)
287
287
  @mutex = Mutex.new
288
288
  @name = name
@@ -297,7 +297,7 @@ module OpenTelemetry
297
297
  @total_recorded_events = 0
298
298
  @total_recorded_links = links&.size || 0
299
299
  @total_recorded_attributes = attributes&.size || 0
300
- @attributes = attributes.nil? ? nil : Hash[attributes] # We need a mutable copy of attributes.
300
+ @attributes = attributes
301
301
  trim_span_attributes(@attributes)
302
302
  @events = nil
303
303
  @links = trim_links(links, span_limits.link_count_limit, span_limits.link_attribute_count_limit)
@@ -317,7 +317,7 @@ module OpenTelemetry
317
317
  # SpanData.
318
318
  @monotonic_start_timestamp = monotonic_now
319
319
  @realtime_start_timestamp = if parent_span.recording?
320
- relative_realtime(parent_span.realtime_start_timestamp, parent_span.monotonic_start_timestamp)
320
+ relative_realtime(parent_span.realtime_start_timestamp, parent_span.monotonic_start_timestamp, @monotonic_start_timestamp)
321
321
  else
322
322
  realtime_now
323
323
  end
@@ -347,8 +347,14 @@ module OpenTelemetry
347
347
  def trim_span_attributes(attrs)
348
348
  return if attrs.nil?
349
349
 
350
- excess = attrs.size - @span_limits.attribute_count_limit
351
- excess.times { attrs.shift } if excess.positive?
350
+ if attrs.size > @span_limits.attribute_count_limit
351
+ n = @span_limits.attribute_count_limit
352
+ attrs.delete_if do |_key, _value|
353
+ n -= 1
354
+ n.negative?
355
+ end
356
+ end
357
+
352
358
  truncate_attribute_values(attrs, @span_limits.attribute_length_limit)
353
359
  nil
354
360
  end
@@ -413,15 +419,15 @@ module OpenTelemetry
413
419
  def relative_timestamp(timestamp)
414
420
  return time_in_nanoseconds(timestamp) unless timestamp.nil?
415
421
 
416
- relative_realtime(realtime_start_timestamp, monotonic_start_timestamp)
422
+ relative_realtime(realtime_start_timestamp, monotonic_start_timestamp, monotonic_now)
417
423
  end
418
424
 
419
425
  def time_in_nanoseconds(timestamp)
420
426
  (timestamp.to_r * 1_000_000_000).to_i
421
427
  end
422
428
 
423
- def relative_realtime(realtime_base, monotonic_base)
424
- realtime_base + (monotonic_now - monotonic_base)
429
+ def relative_realtime(realtime_base, monotonic_base, now)
430
+ realtime_base + (now - monotonic_base)
425
431
  end
426
432
 
427
433
  def realtime_now
@@ -141,7 +141,7 @@ module OpenTelemetry
141
141
  if result.recording? && !@stopped
142
142
  trace_flags = result.sampled? ? OpenTelemetry::Trace::TraceFlags::SAMPLED : OpenTelemetry::Trace::TraceFlags::DEFAULT
143
143
  context = OpenTelemetry::Trace::SpanContext.new(trace_id: trace_id, span_id: span_id, trace_flags: trace_flags, tracestate: result.tracestate)
144
- attributes = attributes&.merge(result.attributes) || result.attributes
144
+ attributes = attributes&.merge(result.attributes) || result.attributes.dup
145
145
  Span.new(
146
146
  context,
147
147
  parent_context,
@@ -7,6 +7,6 @@
7
7
  module OpenTelemetry
8
8
  module SDK
9
9
  ## Current OpenTelemetry version
10
- VERSION = '1.3.0'
10
+ VERSION = '1.3.2'
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.3.0
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenTelemetry Authors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-13 00:00:00.000000000 Z
11
+ date: 2024-01-23 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.3.0/file.CHANGELOG.html
297
+ changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk/v1.3.2/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.3.0
300
+ documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk/v1.3.2
301
301
  post_install_message:
302
302
  rdoc_options: []
303
303
  require_paths: