opentelemetry-sdk 0.7.0 → 0.11.1

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.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +37 -0
  3. data/LICENSE +1 -1
  4. data/lib/opentelemetry-sdk.rb +1 -1
  5. data/lib/opentelemetry/sdk.rb +2 -1
  6. data/lib/opentelemetry/sdk/baggage.rb +1 -1
  7. data/lib/opentelemetry/sdk/baggage/builder.rb +1 -1
  8. data/lib/opentelemetry/sdk/baggage/manager.rb +1 -1
  9. data/lib/opentelemetry/sdk/configurator.rb +1 -1
  10. data/lib/opentelemetry/sdk/instrumentation_library.rb +1 -1
  11. data/lib/opentelemetry/sdk/internal.rb +1 -1
  12. data/lib/opentelemetry/sdk/resources.rb +1 -1
  13. data/lib/opentelemetry/sdk/resources/constants.rb +1 -5
  14. data/lib/opentelemetry/sdk/resources/resource.rb +1 -1
  15. data/lib/opentelemetry/sdk/trace.rb +1 -1
  16. data/lib/opentelemetry/sdk/trace/config.rb +1 -1
  17. data/lib/opentelemetry/sdk/trace/config/trace_config.rb +1 -1
  18. data/lib/opentelemetry/sdk/trace/event.rb +1 -1
  19. data/lib/opentelemetry/sdk/trace/export.rb +2 -1
  20. data/lib/opentelemetry/sdk/trace/export/batch_span_processor.rb +64 -29
  21. data/lib/opentelemetry/sdk/trace/export/console_span_exporter.rb +3 -3
  22. data/lib/opentelemetry/sdk/trace/export/in_memory_span_exporter.rb +5 -3
  23. data/lib/opentelemetry/sdk/trace/export/metrics_reporter.rb +59 -0
  24. data/lib/opentelemetry/sdk/trace/export/multi_span_exporter.rb +15 -17
  25. data/lib/opentelemetry/sdk/trace/export/noop_span_exporter.rb +6 -3
  26. data/lib/opentelemetry/sdk/trace/export/simple_span_processor.rb +12 -4
  27. data/lib/opentelemetry/sdk/trace/multi_span_processor.rb +21 -5
  28. data/lib/opentelemetry/sdk/trace/noop_span_processor.rb +5 -3
  29. data/lib/opentelemetry/sdk/trace/samplers.rb +7 -13
  30. data/lib/opentelemetry/sdk/trace/samplers/constant_sampler.rb +4 -5
  31. data/lib/opentelemetry/sdk/trace/samplers/decision.rb +1 -1
  32. data/lib/opentelemetry/sdk/trace/samplers/parent_based.rb +5 -4
  33. data/lib/opentelemetry/sdk/trace/samplers/result.rb +14 -3
  34. data/lib/opentelemetry/sdk/trace/samplers/trace_id_ratio_based.rb +4 -5
  35. data/lib/opentelemetry/sdk/trace/span.rb +3 -3
  36. data/lib/opentelemetry/sdk/trace/span_data.rb +1 -1
  37. data/lib/opentelemetry/sdk/trace/tracer.rb +11 -11
  38. data/lib/opentelemetry/sdk/trace/tracer_provider.rb +5 -3
  39. data/lib/opentelemetry/sdk/version.rb +2 -2
  40. metadata +24 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b5510dccb3f3f94057ab6f17a625b8c71fbeeb958d2ec2de2eb732bfc59a4225
4
- data.tar.gz: 768a8e36a2a5a34458d6872584339a93d14d83b0302ed998626d21d97d4592b7
3
+ metadata.gz: 640e29efdf46f030e232f9fbb96f43f183438e546b8116eb94f989f83ab06966
4
+ data.tar.gz: b6e023f909b6485b2eecd0ef150e4562c659b4d51856f87b226484c1db56b189
5
5
  SHA512:
6
- metadata.gz: ab2eb7f6eec8f1c62812e8a6f53502a2f29d017489078ede3c5fc4b4b9928435e71658c2cb506b73a16098ef681fffd9d088a028fd6938fec3da0d6a30cc3ec8
7
- data.tar.gz: a1ee4191297bdb3491988e0bca431274f29685057578781e3911bd9f34e66042826aa1528c5eda9172d65beeaf6aeed269185665eb0f6a2361500de09a311c10
6
+ metadata.gz: 5c58bfdb66b128e299ed2742c2327939ef02139c10b825d8ca5fe9a0c241340971e027a53c70de1777c9abf7a3c33e318ef936aa026aa6c4c496d6c0e3132a86
7
+ data.tar.gz: c426b41723e57ddcfbe332f4b4e01982056b47813cc9afb05b4385f7bdeacc91544ee2c707bd98ce4824488ab89b407cc7ba73568e6b954cf7d39aed878f476c
@@ -1,5 +1,42 @@
1
1
  # Release History: opentelemetry-sdk
2
2
 
3
+ ### v0.11.1 / 2020-12-16
4
+
5
+ * FIXED: BSP dropped span buffer full reporting
6
+
7
+ ### v0.11.0 / 2020-12-11
8
+
9
+ * ADDED: Metrics reporting from trace export
10
+ * FIXED: Copyright comments to not reference year
11
+
12
+ ### v0.10.0 / 2020-12-03
13
+
14
+ * BREAKING CHANGE: Allow samplers to modify tracestate
15
+
16
+ * FIXED: Allow samplers to modify tracestate
17
+
18
+ ### v0.9.0 / 2020-11-27
19
+
20
+ * BREAKING CHANGE: Pass full Context to samplers
21
+ * BREAKING CHANGE: Add timeout for force_flush and shutdown
22
+
23
+ * ADDED: Add OTEL_RUBY_BSP_START_THREAD_ON_BOOT env var
24
+ * ADDED: Add timeout for force_flush and shutdown
25
+ * FIXED: Signal at batch_size
26
+ * FIXED: SDK Span.recording? after finish
27
+ * FIXED: Pass full Context to samplers
28
+ * DOCS: Add documentation on usage scenarios for span processors
29
+
30
+ ### v0.8.0 / 2020-10-27
31
+
32
+ * BREAKING CHANGE: Move context/span methods to Trace module
33
+ * BREAKING CHANGE: Remove 'canonical' from status codes
34
+ * BREAKING CHANGE: Assorted SpanContext fixes
35
+
36
+ * FIXED: Move context/span methods to Trace module
37
+ * FIXED: Remove 'canonical' from status codes
38
+ * FIXED: Assorted SpanContext fixes
39
+
3
40
  ### v0.7.0 / 2020-10-07
4
41
 
5
42
  * ADDED: Add service_name setter to configurator
data/LICENSE CHANGED
@@ -186,7 +186,7 @@
186
186
  same "printed page" as the copyright notice for easier
187
187
  identification within third-party archives.
188
188
 
189
- Copyright 2020 OpenTelemetry Authors
189
+ Copyright The OpenTelemetry Authors
190
190
 
191
191
  Licensed under the Apache License, Version 2.0 (the "License");
192
192
  you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2019 OpenTelemetry Authors
3
+ # Copyright The OpenTelemetry Authors
4
4
  #
5
5
  # SPDX-License-Identifier: Apache-2.0
6
6
 
@@ -1,10 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2019 OpenTelemetry Authors
3
+ # Copyright The OpenTelemetry Authors
4
4
  #
5
5
  # SPDX-License-Identifier: Apache-2.0
6
6
 
7
7
  require 'opentelemetry'
8
+ require 'opentelemetry/common'
8
9
 
9
10
  # OpenTelemetry is an open source observability framework, providing a
10
11
  # general-purpose API, SDK, and related tools required for the instrumentation
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2019 OpenTelemetry Authors
3
+ # Copyright The OpenTelemetry Authors
4
4
  #
5
5
  # SPDX-License-Identifier: Apache-2.0
6
6
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2019 OpenTelemetry Authors
3
+ # Copyright The OpenTelemetry Authors
4
4
  #
5
5
  # SPDX-License-Identifier: Apache-2.0
6
6
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2019 OpenTelemetry Authors
3
+ # Copyright The OpenTelemetry Authors
4
4
  #
5
5
  # SPDX-License-Identifier: Apache-2.0
6
6
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2019 OpenTelemetry Authors
3
+ # Copyright The OpenTelemetry Authors
4
4
  #
5
5
  # SPDX-License-Identifier: Apache-2.0
6
6
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2019 OpenTelemetry Authors
3
+ # Copyright The OpenTelemetry Authors
4
4
  #
5
5
  # SPDX-License-Identifier: Apache-2.0
6
6
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2019 OpenTelemetry Authors
3
+ # Copyright The OpenTelemetry Authors
4
4
  #
5
5
  # SPDX-License-Identifier: Apache-2.0
6
6
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2019 OpenTelemetry Authors
3
+ # Copyright The OpenTelemetry Authors
4
4
  #
5
5
  # SPDX-License-Identifier: Apache-2.0
6
6
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2020 OpenTelemetry Authors
3
+ # Copyright The OpenTelemetry Authors
4
4
  #
5
5
  # SPDX-License-Identifier: Apache-2.0
6
6
 
@@ -79,10 +79,6 @@ module OpenTelemetry
79
79
 
80
80
  # Attributes defining a computing instance (e.g. host).
81
81
  HOST_RESOURCE = {
82
- # Hostname of the host. It contains what the hostname command returns on the
83
- # host machine.
84
- hostname: 'host.hostname',
85
-
86
82
  # Unique host id. For Cloud this must be the instance_id assigned by the
87
83
  # cloud provider
88
84
  id: 'host.id',
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2019 OpenTelemetry Authors
3
+ # Copyright The OpenTelemetry Authors
4
4
  #
5
5
  # SPDX-License-Identifier: Apache-2.0
6
6
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2019 OpenTelemetry Authors
3
+ # Copyright The OpenTelemetry Authors
4
4
  #
5
5
  # SPDX-License-Identifier: Apache-2.0
6
6
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2019 OpenTelemetry Authors
3
+ # Copyright The OpenTelemetry Authors
4
4
  #
5
5
  # SPDX-License-Identifier: Apache-2.0
6
6
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2019 OpenTelemetry Authors
3
+ # Copyright The OpenTelemetry Authors
4
4
  #
5
5
  # SPDX-License-Identifier: Apache-2.0
6
6
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2019 OpenTelemetry Authors
3
+ # Copyright The OpenTelemetry Authors
4
4
  #
5
5
  # SPDX-License-Identifier: Apache-2.0
6
6
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2019 OpenTelemetry Authors
3
+ # Copyright The OpenTelemetry Authors
4
4
  #
5
5
  # SPDX-License-Identifier: Apache-2.0
6
6
 
@@ -30,6 +30,7 @@ end
30
30
  require 'opentelemetry/sdk/trace/export/batch_span_processor'
31
31
  require 'opentelemetry/sdk/trace/export/console_span_exporter'
32
32
  require 'opentelemetry/sdk/trace/export/in_memory_span_exporter'
33
+ require 'opentelemetry/sdk/trace/export/metrics_reporter'
33
34
  require 'opentelemetry/sdk/trace/export/multi_span_exporter'
34
35
  require 'opentelemetry/sdk/trace/export/noop_span_exporter'
35
36
  require 'opentelemetry/sdk/trace/export/simple_span_processor'
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2019 OpenTelemetry Authors
3
+ # Copyright The OpenTelemetry Authors
4
4
  #
5
5
  # SPDX-License-Identifier: Apache-2.0
6
6
 
@@ -13,6 +13,9 @@ module OpenTelemetry
13
13
  # Implementation of the duck type SpanProcessor that batches spans
14
14
  # exported by the SDK then pushes them to the exporter pipeline.
15
15
  #
16
+ # Typically, the BatchSpanProcessor will be more suitable for
17
+ # production environments than the SimpleSpanProcessor.
18
+ #
16
19
  # All spans reported by the SDK implementation are first added to a
17
20
  # synchronized queue (with a {max_queue_size} maximum size, after the
18
21
  # size is reached spans are dropped) and exported every
@@ -22,7 +25,7 @@ module OpenTelemetry
22
25
  # If the queue gets half full a preemptive notification is sent to the
23
26
  # worker thread that exports the spans to wake up and start a new
24
27
  # export cycle.
25
- class BatchSpanProcessor
28
+ class BatchSpanProcessor # rubocop:disable Metrics/ClassLength
26
29
  # Returns a new instance of the {BatchSpanProcessor}.
27
30
  #
28
31
  # @param [SpanExporter] exporter
@@ -44,29 +47,31 @@ module OpenTelemetry
44
47
  exporter_timeout_millis: Float(ENV.fetch('OTEL_BSP_EXPORT_TIMEOUT_MILLIS', 30_000)),
45
48
  schedule_delay_millis: Float(ENV.fetch('OTEL_BSP_SCHEDULE_DELAY_MILLIS', 5_000)),
46
49
  max_queue_size: Integer(ENV.fetch('OTEL_BSP_MAX_QUEUE_SIZE', 2048)),
47
- max_export_batch_size: Integer(ENV.fetch('OTEL_BSP_MAX_EXPORT_BATCH_SIZE', 512)))
50
+ max_export_batch_size: Integer(ENV.fetch('OTEL_BSP_MAX_EXPORT_BATCH_SIZE', 512)),
51
+ start_thread_on_boot: String(ENV['OTEL_RUBY_BSP_START_THREAD_ON_BOOT']) !~ /false/i,
52
+ metrics_reporter: nil)
48
53
  raise ArgumentError if max_export_batch_size > max_queue_size
49
54
 
50
55
  @exporter = exporter
51
56
  @exporter_timeout_seconds = exporter_timeout_millis / 1000.0
52
57
  @mutex = Mutex.new
58
+ @export_mutex = Mutex.new
53
59
  @condition = ConditionVariable.new
54
60
  @keep_running = true
55
61
  @delay_seconds = schedule_delay_millis / 1000.0
56
62
  @max_queue_size = max_queue_size
57
63
  @batch_size = max_export_batch_size
64
+ @metrics_reporter = metrics_reporter || OpenTelemetry::SDK::Trace::Export::MetricsReporter
58
65
  @spans = []
59
66
  @pid = nil
60
67
  @thread = nil
61
- reset_on_fork
68
+ reset_on_fork(restart_thread: start_thread_on_boot)
62
69
  end
63
70
 
64
- # does nothing for this processor
65
- def on_start(span, parent_context)
66
- # noop
67
- end
71
+ # Does nothing for this processor
72
+ def on_start(_span, _parent_context); end
68
73
 
69
- # adds a span to the batcher, threadsafe may block on lock
74
+ # Adds a span to the batch. Thread-safe; may block on lock.
70
75
  def on_finish(span) # rubocop:disable Metrics/AbcSize
71
76
  return unless span.context.trace_flags.sampled?
72
77
 
@@ -74,12 +79,12 @@ module OpenTelemetry
74
79
  reset_on_fork
75
80
  n = spans.size + 1 - max_queue_size
76
81
  spans.shift(n) if n.positive?
82
+ report_dropped_spans(n, reason: 'buffer-full')
77
83
  spans << span
78
- @condition.signal if spans.size > max_queue_size / 2
84
+ @condition.signal if spans.size > batch_size
79
85
  end
80
86
  end
81
87
 
82
- # TODO: test this explicitly.
83
88
  # Export all ended spans to the configured `Exporter` that have not yet
84
89
  # been exported.
85
90
  #
@@ -88,42 +93,64 @@ module OpenTelemetry
88
93
  # the process after an invocation, but before the `Processor` exports
89
94
  # the completed spans.
90
95
  #
96
+ # @param [optional Numeric] timeout An optional timeout in seconds.
91
97
  # @return [Integer] SUCCESS if no error occurred, FAILURE if a
92
98
  # non-specific failure occurred, TIMEOUT if a timeout occurred.
93
- def force_flush
99
+ def force_flush(timeout: nil) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength
100
+ start_time = Time.now
94
101
  snapshot = lock do
95
102
  reset_on_fork(restart_thread: false) if @keep_running
96
103
  spans.shift(spans.size)
97
104
  end
98
105
  until snapshot.empty?
106
+ remaining_timeout = OpenTelemetry::Common::Utilities.maybe_timeout(timeout, start_time)
107
+ return TIMEOUT if remaining_timeout&.zero?
108
+
99
109
  batch = snapshot.shift(@batch_size).map!(&:to_span_data)
100
- result_code = @exporter.export(batch)
101
- report_result(result_code, batch)
110
+ result_code = export_batch(batch, timeout: remaining_timeout)
111
+ return result_code unless result_code == SUCCESS
102
112
  end
113
+
103
114
  SUCCESS
115
+ ensure
116
+ # Unshift the remaining spans if we timed out. We drop excess spans from
117
+ # the snapshot because they're older than any spans in the spans buffer.
118
+ lock do
119
+ n = spans.size + snapshot.size - max_queue_size
120
+ if n.positive?
121
+ snapshot.shift(n)
122
+ report_dropped_spans(n, reason: 'buffer-full')
123
+ end
124
+ spans.unshift(snapshot) unless snapshot.empty?
125
+ @condition.signal if spans.size > max_queue_size / 2
126
+ end
104
127
  end
105
128
 
106
- # shuts the consumer thread down and flushes the current accumulated buffer
107
- # will block until the thread is finished
129
+ # Shuts the consumer thread down and flushes the current accumulated buffer
130
+ # will block until the thread is finished.
108
131
  #
132
+ # @param [optional Numeric] timeout An optional timeout in seconds.
109
133
  # @return [Integer] SUCCESS if no error occurred, FAILURE if a
110
134
  # non-specific failure occurred, TIMEOUT if a timeout occurred.
111
- def shutdown
135
+ def shutdown(timeout: nil)
136
+ start_time = Time.now
112
137
  lock do
113
138
  @keep_running = false
114
139
  @condition.signal
115
140
  end
116
141
 
117
- @thread.join
118
- force_flush
119
- @exporter.shutdown
142
+ @thread.join(timeout)
143
+ force_flush(timeout: OpenTelemetry::Common::Utilities.maybe_timeout(timeout, start_time))
144
+ @exporter.shutdown(timeout: OpenTelemetry::Common::Utilities.maybe_timeout(timeout, start_time))
145
+ dropped_spans = lock { spans.size }
146
+ report_dropped_spans(dropped_spans, reason: 'terminating') if dropped_spans.positive?
120
147
  end
121
148
 
122
149
  private
123
150
 
124
151
  attr_reader :spans, :max_queue_size, :batch_size
125
152
 
126
- def work
153
+ def work # rubocop:disable Metrics/AbcSize
127
154
  loop do
128
155
  batch = lock do
129
156
  reset_on_fork(restart_thread: false)
@@ -134,6 +161,8 @@ module OpenTelemetry
134
161
  fetch_batch
135
162
  end
136
163
 
164
+ @metrics_reporter.observe_value('otel.bsp.buffer_utilization', value: spans.size / max_queue_size.to_f)
165
+
137
166
  export_batch(batch)
138
167
  end
139
168
  end
@@ -147,19 +176,25 @@ module OpenTelemetry
147
176
  @thread = Thread.new { work } if restart_thread
148
177
  end
149
178
 
150
- def export_batch(batch)
151
- result_code = export_with_timeout(batch)
179
+ def export_batch(batch, timeout: @exporter_timeout_seconds)
180
+ result_code = @export_mutex.synchronize { @exporter.export(batch, timeout: timeout) }
152
181
  report_result(result_code, batch)
182
+ result_code
153
183
  end
154
184
 
155
- def export_with_timeout(batch)
156
- Timeout.timeout(@exporter_timeout_seconds) { @exporter.export(batch) }
157
- rescue Timeout::Error
158
- FAILURE
185
+ def report_result(result_code, batch)
186
+ if result_code == SUCCESS
187
+ @metrics_reporter.add_to_counter('otel.bsp.export.success')
188
+ @metrics_reporter.add_to_counter('otel.bsp.exported_spans', increment: batch.size)
189
+ else
190
+ OpenTelemetry.logger.error("Unable to export #{batch.size} spans")
191
+ @metrics_reporter.add_to_counter('otel.bsp.export.failure')
192
+ report_dropped_spans(batch.size, reason: 'export-failure')
193
+ end
159
194
  end
160
195
 
161
- def report_result(result_code, batch)
162
- OpenTelemetry.logger.error("Unable to export #{batch.size} spans") unless result_code == SUCCESS
196
+ def report_dropped_spans(count, reason:)
197
+ @metrics_reporter.add_to_counter('otel.bsp.dropped_spans', increment: count, labels: { 'reason' => reason })
163
198
  end
164
199
 
165
200
  def fetch_batch
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2019 OpenTelemetry Authors
3
+ # Copyright The OpenTelemetry Authors
4
4
  #
5
5
  # SPDX-License-Identifier: Apache-2.0
6
6
 
@@ -18,7 +18,7 @@ module OpenTelemetry
18
18
  @stopped = false
19
19
  end
20
20
 
21
- def export(spans)
21
+ def export(spans, timeout: nil)
22
22
  return FAILURE if @stopped
23
23
 
24
24
  Array(spans).each { |s| pp s }
@@ -26,7 +26,7 @@ module OpenTelemetry
26
26
  SUCCESS
27
27
  end
28
28
 
29
- def shutdown
29
+ def shutdown(timeout: nil)
30
30
  @stopped = true
31
31
  SUCCESS
32
32
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2019 OpenTelemetry Authors
3
+ # Copyright The OpenTelemetry Authors
4
4
  #
5
5
  # SPDX-License-Identifier: Apache-2.0
6
6
 
@@ -60,9 +60,10 @@ module OpenTelemetry
60
60
  #
61
61
  # @param [Enumerable<SpanData>] span_datas the list of sampled {SpanData}s to be
62
62
  # exported.
63
+ # @param [optional Numeric] timeout An optional timeout in seconds.
63
64
  # @return [Integer] the result of the export, SUCCESS or
64
65
  # FAILURE
65
- def export(span_datas)
66
+ def export(span_datas, timeout: nil)
66
67
  @mutex.synchronize do
67
68
  return FAILURE if @stopped
68
69
 
@@ -74,9 +75,10 @@ module OpenTelemetry
74
75
  # Called when {TracerProvider#shutdown} is called, if this exporter is
75
76
  # registered to a {TracerProvider} object.
76
77
  #
78
+ # @param [optional Numeric] timeout An optional timeout in seconds.
77
79
  # @return [Integer] SUCCESS if no error occurred, FAILURE if a
78
80
  # non-specific failure occurred, TIMEOUT if a timeout occurred.
79
- def shutdown
81
+ def shutdown(timeout: nil)
80
82
  @mutex.synchronize do
81
83
  @finished_spans.clear
82
84
  @stopped = true
@@ -0,0 +1,59 @@
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
+ module Trace
10
+ module Export
11
+ # MetricsReporter defines an interface used for reporting metrics from
12
+ # span processors (like the BatchSpanProcessor) and exporters. It can
13
+ # be used to report metrics such as dropped spans, and successful and
14
+ # failed export attempts. This exists to decouple the Trace SDK from
15
+ # the unstable OpenTelemetry Metrics API. An example implementation in
16
+ # terms of StatsD is:
17
+ #
18
+ # module MetricsReporter
19
+ # def add_to_counter(metric, increment: 1, labels: {})
20
+ # StatsD.increment(metric, increment, labels, no_prefix: true)
21
+ # end
22
+ # def record_value(metric, value:, labels: {})
23
+ # StatsD.distribution(metric, value, labels, no_prefix: true)
24
+ # end
25
+ # def observe_value(metric, value:, labels: {})
26
+ # StatsD.gauge(metric, value, labels, no_prefix: true)
27
+ # end
28
+ # end
29
+ module MetricsReporter
30
+ extend self
31
+
32
+ # Adds an increment to a metric with the provided labels.
33
+ #
34
+ # @param [String] metric The metric name.
35
+ # @param [optional Numeric] increment An optional increment to report.
36
+ # @param [optional Hash<String, String>] labels Optional labels to
37
+ # associate with the metric.
38
+ def add_to_counter(metric, increment: 1, labels: {}); end
39
+
40
+ # Records a value for a metric with the provided labels.
41
+ #
42
+ # @param [String] metric The metric name.
43
+ # @param [Numeric] value The value to report.
44
+ # @param [optional Hash<String, String>] labels Optional labels to
45
+ # associate with the metric.
46
+ def record_value(metric, value:, labels: {}); end
47
+
48
+ # Observes a value for a metric with the provided labels.
49
+ #
50
+ # @param [String] metric The metric name.
51
+ # @param [Numeric] value The value to observe.
52
+ # @param [optional Hash<String, String>] labels Optional labels to
53
+ # associate with the metric.
54
+ def observe_value(metric, value:, labels: {}); end
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2019 OpenTelemetry Authors
3
+ # Copyright The OpenTelemetry Authors
4
4
  #
5
5
  # SPDX-License-Identifier: Apache-2.0
6
6
 
@@ -23,36 +23,34 @@ module OpenTelemetry
23
23
  #
24
24
  # @param [Enumerable<Span>] spans the list of sampled {Span}s to be
25
25
  # exported.
26
+ # @param [optional Numeric] timeout An optional timeout in seconds.
26
27
  # @return [Integer] the result of the export.
27
- def export(spans)
28
- @span_exporters.inject(SUCCESS) do |result_code, span_exporter|
29
- merge_result_code(result_code, span_exporter.export(spans))
28
+ def export(spans, timeout: nil)
29
+ start_time = Time.now
30
+ results = @span_exporters.map do |span_exporter|
31
+ span_exporter.export(spans, timeout: OpenTelemetry::Common::Utilities.maybe_timeout(timeout, start_time))
30
32
  rescue => e # rubocop:disable Style/RescueStandardError
31
33
  OpenTelemetry.logger.warn("exception raised by export - #{e}")
32
34
  FAILURE
33
35
  end
36
+ results.uniq.max || SUCCESS
34
37
  end
35
38
 
36
39
  # Called when {TracerProvider#shutdown} is called, if this exporter is
37
40
  # registered to a {TracerProvider} object.
38
41
  #
42
+ # @param [optional Numeric] timeout An optional timeout in seconds.
39
43
  # @return [Integer] SUCCESS if no error occurred, FAILURE if a
40
44
  # non-specific failure occurred, TIMEOUT if a timeout occurred.
41
- def shutdown
42
- @span_exporters.map(&:shutdown).uniq.max
43
- end
44
-
45
- private
45
+ def shutdown(timeout: nil)
46
+ start_time = Time.now
47
+ results = @span_exporters.map do |processor|
48
+ remaining_timeout = OpenTelemetry::Common::Utilities.maybe_timeout(timeout, start_time)
49
+ return TIMEOUT if remaining_timeout&.zero?
46
50
 
47
- # Returns a merged error code, see the rules in the code.
48
- def merge_result_code(result_code, new_result_code)
49
- if result_code == SUCCESS && new_result_code == SUCCESS
50
- # If both errors are success then return success.
51
- SUCCESS
52
- else
53
- # At this point at least one of the code is FAILURE, so return FAILURE.
54
- FAILURE
51
+ processor.shutdown(timeout: remaining_timeout)
55
52
  end
53
+ results.uniq.max || SUCCESS
56
54
  end
57
55
  end
58
56
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2019 OpenTelemetry Authors
3
+ # Copyright The OpenTelemetry Authors
4
4
  #
5
5
  # SPDX-License-Identifier: Apache-2.0
6
6
 
@@ -23,8 +23,9 @@ module OpenTelemetry
23
23
  #
24
24
  # @param [Enumerable<Span>] spans the list of sampled {Span}s to be
25
25
  # exported.
26
+ # @param [optional Numeric] timeout An optional timeout in seconds.
26
27
  # @return [Integer] the result of the export.
27
- def export(spans)
28
+ def export(spans, timeout: nil)
28
29
  return SUCCESS unless @stopped
29
30
 
30
31
  FAILURE
@@ -32,7 +33,9 @@ module OpenTelemetry
32
33
 
33
34
  # Called when {TracerProvider#shutdown} is called, if this exporter is
34
35
  # registered to a {TracerProvider} object.
35
- def shutdown
36
+ #
37
+ # @param [optional Numeric] timeout An optional timeout in seconds.
38
+ def shutdown(timeout: nil)
36
39
  @stopped = true
37
40
  SUCCESS
38
41
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2019 OpenTelemetry Authors
3
+ # Copyright The OpenTelemetry Authors
4
4
  #
5
5
  # SPDX-License-Identifier: Apache-2.0
6
6
 
@@ -12,6 +12,12 @@ module OpenTelemetry
12
12
  # {Span} to {io.opentelemetry.proto.trace.v1.Span} and passes it to the
13
13
  # configured exporter.
14
14
  #
15
+ # Typically, the SimpleSpanProcessor will be most suitable for use in testing;
16
+ # it should be used with caution in production. It may be appropriate for
17
+ # production use in scenarios where creating multiple threads is not desirable
18
+ # as well as scenarios where different custom attributes should be added to
19
+ # individual spans based on code scopes.
20
+ #
15
21
  # Only spans that are recorded are converted, {OpenTelemetry::Trace::Span#is_recording?} must
16
22
  # return true.
17
23
  class SimpleSpanProcessor
@@ -62,18 +68,20 @@ module OpenTelemetry
62
68
  # the process after an invocation, but before the `Processor` exports
63
69
  # the completed spans.
64
70
  #
71
+ # @param [optional Numeric] timeout An optional timeout in seconds.
65
72
  # @return [Integer] SUCCESS if no error occurred, FAILURE if a
66
73
  # non-specific failure occurred, TIMEOUT if a timeout occurred.
67
- def force_flush
74
+ def force_flush(timeout: nil)
68
75
  SUCCESS
69
76
  end
70
77
 
71
78
  # Called when {TracerProvider#shutdown} is called.
72
79
  #
80
+ # @param [optional Numeric] timeout An optional timeout in seconds.
73
81
  # @return [Integer] SUCCESS if no error occurred, FAILURE if a
74
82
  # non-specific failure occurred, TIMEOUT if a timeout occurred.
75
- def shutdown
76
- @span_exporter&.shutdown || SUCCESS
83
+ def shutdown(timeout: nil)
84
+ @span_exporter&.shutdown(timeout: timeout) || SUCCESS
77
85
  end
78
86
  end
79
87
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2019 OpenTelemetry Authors
3
+ # Copyright The OpenTelemetry Authors
4
4
  #
5
5
  # SPDX-License-Identifier: Apache-2.0
6
6
 
@@ -51,18 +51,34 @@ module OpenTelemetry
51
51
  # the process after an invocation, but before the `Processor` exports
52
52
  # the completed spans.
53
53
  #
54
+ # @param [optional Numeric] timeout An optional timeout in seconds.
54
55
  # @return [Integer] Export::SUCCESS if no error occurred, Export::FAILURE if
55
56
  # a non-specific failure occurred, Export::TIMEOUT if a timeout occurred.
56
- def force_flush
57
- @span_processors.map(&:force_flush).uniq.max
57
+ def force_flush(timeout: nil)
58
+ start_time = Time.now
59
+ results = @span_processors.map do |processor|
60
+ remaining_timeout = OpenTelemetry::Common::Utilities.maybe_timeout(timeout, start_time)
61
+ return Export::TIMEOUT if remaining_timeout&.zero?
62
+
63
+ processor.force_flush(timeout: remaining_timeout)
64
+ end
65
+ results.uniq.max
58
66
  end
59
67
 
60
68
  # Called when {TracerProvider#shutdown} is called.
61
69
  #
70
+ # @param [optional Numeric] timeout An optional timeout in seconds.
62
71
  # @return [Integer] Export::SUCCESS if no error occurred, Export::FAILURE if
63
72
  # a non-specific failure occurred, Export::TIMEOUT if a timeout occurred.
64
- def shutdown
65
- @span_processors.map(&:shutdown).uniq.max
73
+ def shutdown(timeout: nil)
74
+ start_time = Time.now
75
+ results = @span_processors.map do |processor|
76
+ remaining_timeout = OpenTelemetry::Common::Utilities.maybe_timeout(timeout, start_time)
77
+ return Export::TIMEOUT if remaining_timeout&.zero?
78
+
79
+ processor.shutdown(timeout: remaining_timeout)
80
+ end
81
+ results.uniq.max
66
82
  end
67
83
  end
68
84
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2019 OpenTelemetry Authors
3
+ # Copyright The OpenTelemetry Authors
4
4
  #
5
5
  # SPDX-License-Identifier: Apache-2.0
6
6
 
@@ -43,17 +43,19 @@ module OpenTelemetry
43
43
  # the process after an invocation, but before the `Processor` exports
44
44
  # the completed spans.
45
45
  #
46
+ # @param [optional Numeric] timeout An optional timeout in seconds.
46
47
  # @return [Integer] Export::SUCCESS if no error occurred, Export::FAILURE if
47
48
  # a non-specific failure occurred, Export::TIMEOUT if a timeout occurred.
48
- def force_flush
49
+ def force_flush(timeout: nil)
49
50
  Export::SUCCESS
50
51
  end
51
52
 
52
53
  # Called when {TracerProvider#shutdown} is called.
53
54
  #
55
+ # @param [optional Numeric] timeout An optional timeout in seconds.
54
56
  # @return [Integer] Export::SUCCESS if no error occurred, Export::FAILURE if
55
57
  # a non-specific failure occurred, Export::TIMEOUT if a timeout occurred.
56
- def shutdown
58
+ def shutdown(timeout: nil)
57
59
  Export::SUCCESS
58
60
  end
59
61
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2019 OpenTelemetry Authors
3
+ # Copyright The OpenTelemetry Authors
4
4
  #
5
5
  # SPDX-License-Identifier: Apache-2.0
6
6
 
@@ -25,9 +25,10 @@ module OpenTelemetry
25
25
  # Where:
26
26
  #
27
27
  # @param [String] trace_id The trace_id of the {Span} to be created.
28
- # @param [OpenTelemetry::Trace::SpanContext] parent_context The
29
- # {OpenTelemetry::Trace::SpanContext} of a parent span, typically
30
- # extracted from the wire. Can be nil for a root span.
28
+ # @param [OpenTelemetry::Context] parent_context The
29
+ # {OpenTelemetry::Context} with a parent {Span}. The {Span}'s
30
+ # {OpenTelemetry::Trace::SpanContext} may be invalid to indicate a
31
+ # root span.
31
32
  # @param [Enumerable<Link>] links A collection of links to be associated
32
33
  # with the {Span} to be created. Can be nil.
33
34
  # @param [String] name Name of the {Span} to be created.
@@ -37,18 +38,11 @@ module OpenTelemetry
37
38
  # to the {Span} to be created. Can be nil.
38
39
  # @return [Result] The sampling result.
39
40
  module Samplers
40
- RECORD_AND_SAMPLE = Result.new(decision: Decision::RECORD_AND_SAMPLE)
41
- DROP = Result.new(decision: Decision::DROP)
42
- RECORD_ONLY = Result.new(decision: Decision::RECORD_ONLY)
43
- SAMPLING_HINTS = [Decision::DROP, Decision::RECORD_ONLY, Decision::RECORD_AND_SAMPLE].freeze
44
-
45
- private_constant(:RECORD_AND_SAMPLE, :DROP, :RECORD_ONLY, :SAMPLING_HINTS)
46
-
47
41
  # Returns a {Result} with {Decision::RECORD_AND_SAMPLE}.
48
- ALWAYS_ON = ConstantSampler.new(result: RECORD_AND_SAMPLE, description: 'AlwaysOnSampler')
42
+ ALWAYS_ON = ConstantSampler.new(decision: Decision::RECORD_AND_SAMPLE, description: 'AlwaysOnSampler')
49
43
 
50
44
  # Returns a {Result} with {Decision::DROP}.
51
- ALWAYS_OFF = ConstantSampler.new(result: DROP, description: 'AlwaysOffSampler')
45
+ ALWAYS_OFF = ConstantSampler.new(decision: Decision::DROP, description: 'AlwaysOffSampler')
52
46
 
53
47
  # Returns a new sampler. It delegates to samplers according to the following rules:
54
48
  #
@@ -10,12 +10,12 @@ module OpenTelemetry
10
10
  module Samplers
11
11
  # @api private
12
12
  #
13
- # Implements a sampler returning a constant result.
13
+ # Implements a sampler returning a result with a constant decision.
14
14
  class ConstantSampler
15
15
  attr_reader :description
16
16
 
17
- def initialize(result:, description:)
18
- @result = result
17
+ def initialize(decision:, description:)
18
+ @decision = decision
19
19
  @description = description
20
20
  end
21
21
 
@@ -23,8 +23,7 @@ module OpenTelemetry
23
23
  #
24
24
  # See {Samplers}.
25
25
  def should_sample?(trace_id:, parent_context:, links:, name:, kind:, attributes:)
26
- # All arguments ignored for sampling decision.
27
- @result
26
+ Result.new(decision: @decision, tracestate: OpenTelemetry::Trace.current_span(parent_context).context.tracestate)
28
27
  end
29
28
  end
30
29
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2019 OpenTelemetry Authors
3
+ # Copyright The OpenTelemetry Authors
4
4
  #
5
5
  # SPDX-License-Identifier: Apache-2.0
6
6
 
@@ -37,12 +37,13 @@ module OpenTelemetry
37
37
  #
38
38
  # See {Samplers}.
39
39
  def should_sample?(trace_id:, parent_context:, links:, name:, kind:, attributes:)
40
- delegate = if parent_context.nil?
40
+ parent_span_context = OpenTelemetry::Trace.current_span(parent_context).context
41
+ delegate = if !parent_span_context.valid?
41
42
  @root
42
- elsif parent_context.remote?
43
- parent_context.trace_flags.sampled? ? @remote_parent_sampled : @remote_parent_not_sampled
43
+ elsif parent_span_context.remote?
44
+ parent_span_context.trace_flags.sampled? ? @remote_parent_sampled : @remote_parent_not_sampled
44
45
  else
45
- parent_context.trace_flags.sampled? ? @local_parent_sampled : @local_parent_not_sampled
46
+ parent_span_context.trace_flags.sampled? ? @local_parent_sampled : @local_parent_not_sampled
46
47
  end
47
48
  delegate.should_sample?(trace_id: trace_id, parent_context: parent_context, links: links, name: name, kind: kind, attributes: attributes)
48
49
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2019 OpenTelemetry Authors
3
+ # Copyright The OpenTelemetry Authors
4
4
  #
5
5
  # SPDX-License-Identifier: Apache-2.0
6
6
 
@@ -17,11 +17,16 @@ module OpenTelemetry
17
17
  DECISIONS = [Decision::RECORD_ONLY, Decision::DROP, Decision::RECORD_AND_SAMPLE].freeze
18
18
  private_constant(:EMPTY_HASH, :DECISIONS)
19
19
 
20
- # Returns a frozen hash of attributes to be attached span.
20
+ # Returns a frozen hash of attributes to be attached to the span.
21
21
  #
22
22
  # @return [Hash{String => String, Numeric, Boolean, Array<String, Numeric, Boolean>}]
23
23
  attr_reader :attributes
24
24
 
25
+ # Returns a Tracestate to be associated with the span.
26
+ #
27
+ # @return [Tracestate]
28
+ attr_reader :tracestate
29
+
25
30
  # Returns a new sampling result with the specified decision and
26
31
  # attributes.
27
32
  #
@@ -30,9 +35,15 @@ module OpenTelemetry
30
35
  # @param [optional Hash{String => String, Numeric, Boolean, Array<String, Numeric, Boolean>}]
31
36
  # attributes A frozen or freezable hash containing attributes to be
32
37
  # attached to the span.
33
- def initialize(decision:, attributes: nil)
38
+ # @param [Tracestate] tracestate A Tracestate that will be associated
39
+ # with the Span through the new SpanContext. If the sampler returns
40
+ # an empty Tracestate here, the Tracestate will be cleared, so
41
+ # samplers SHOULD normally return the passed-in Tracestate if they
42
+ # do not intend to change it.
43
+ def initialize(decision:, attributes: nil, tracestate:)
34
44
  @decision = decision
35
45
  @attributes = attributes.freeze || EMPTY_HASH
46
+ @tracestate = tracestate
36
47
  end
37
48
 
38
49
  # Returns true if this span should be sampled.
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2019 OpenTelemetry Authors
3
+ # Copyright The OpenTelemetry Authors
4
4
  #
5
5
  # SPDX-License-Identifier: Apache-2.0
6
6
 
@@ -24,12 +24,11 @@ module OpenTelemetry
24
24
  #
25
25
  # See {Samplers}.
26
26
  def should_sample?(trace_id:, parent_context:, links:, name:, kind:, attributes:)
27
- # Ignored for sampling decision: parent_context:, links, name, kind, attributes.
28
-
27
+ tracestate = OpenTelemetry::Trace.current_span(parent_context).context.tracestate
29
28
  if sample?(trace_id)
30
- RECORD_AND_SAMPLE
29
+ Result.new(decision: Decision::RECORD_AND_SAMPLE, tracestate: tracestate)
31
30
  else
32
- DROP
31
+ Result.new(decision: Decision::DROP, tracestate: tracestate)
33
32
  end
34
33
  end
35
34
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2019 OpenTelemetry Authors
3
+ # Copyright The OpenTelemetry Authors
4
4
  #
5
5
  # SPDX-License-Identifier: Apache-2.0
6
6
 
@@ -52,7 +52,7 @@ module OpenTelemetry
52
52
  # like events with the #add_event operation and attributes using
53
53
  # #set_attribute.
54
54
  def recording?
55
- true
55
+ !@ended
56
56
  end
57
57
 
58
58
  # Set attribute
@@ -294,7 +294,7 @@ module OpenTelemetry
294
294
  attrs.keep_if { |key, value| Internal.valid_key?(key) && Internal.valid_value?(value) }
295
295
  excess = attrs.size - max_attributes_per_link
296
296
  excess.times { attrs.shift } if excess.positive?
297
- OpenTelemetry::Trace::Link.new(link.context, attrs)
297
+ OpenTelemetry::Trace::Link.new(link.span_context, attrs)
298
298
  end.freeze
299
299
  end
300
300
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2019 OpenTelemetry Authors
3
+ # Copyright The OpenTelemetry Authors
4
4
  #
5
5
  # SPDX-License-Identifier: Apache-2.0
6
6
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2020 OpenTelemetry Authors
3
+ # Copyright The OpenTelemetry Authors
4
4
  #
5
5
  # SPDX-License-Identifier: Apache-2.0
6
6
 
@@ -33,27 +33,27 @@ module OpenTelemetry
33
33
  start_span(name, with_parent: Context.empty, attributes: attributes, links: links, start_timestamp: start_timestamp, kind: kind)
34
34
  end
35
35
 
36
- def start_span(name, with_parent: nil, attributes: nil, links: nil, start_timestamp: nil, kind: nil) # rubocop:disable Metrics/AbcSize
36
+ def start_span(name, with_parent: nil, attributes: nil, links: nil, start_timestamp: nil, kind: nil)
37
37
  name ||= 'empty'
38
38
 
39
39
  with_parent ||= Context.current
40
- parent_span_context = current_span(with_parent).context
41
- parent_span_context = nil unless parent_span_context.valid?
42
- parent_span_id = parent_span_context&.span_id
43
- tracestate = parent_span_context&.tracestate
44
- trace_id = parent_span_context&.trace_id
40
+ parent_span_context = OpenTelemetry::Trace.current_span(with_parent).context
41
+ if parent_span_context.valid?
42
+ parent_span_id = parent_span_context.span_id
43
+ trace_id = parent_span_context.trace_id
44
+ end
45
45
  trace_id ||= OpenTelemetry::Trace.generate_trace_id
46
46
  sampler = tracer_provider.active_trace_config.sampler
47
- result = sampler.should_sample?(trace_id: trace_id, parent_context: parent_span_context, links: links, name: name, kind: kind, attributes: attributes)
48
- internal_create_span(result, name, kind, trace_id, parent_span_id, attributes, links, start_timestamp, tracestate, with_parent)
47
+ result = sampler.should_sample?(trace_id: trace_id, parent_context: with_parent, links: links, name: name, kind: kind, attributes: attributes)
48
+ internal_create_span(result, name, kind, trace_id, parent_span_id, attributes, links, start_timestamp, with_parent)
49
49
  end
50
50
 
51
51
  private
52
52
 
53
- def internal_create_span(result, name, kind, trace_id, parent_span_id, attributes, links, start_timestamp, tracestate, parent_context) # rubocop:disable Metrics/AbcSize
53
+ def internal_create_span(result, name, kind, trace_id, parent_span_id, attributes, links, start_timestamp, parent_context) # rubocop:disable Metrics/AbcSize
54
54
  if result.recording? && !tracer_provider.stopped?
55
55
  trace_flags = result.sampled? ? OpenTelemetry::Trace::TraceFlags::SAMPLED : OpenTelemetry::Trace::TraceFlags::DEFAULT
56
- context = OpenTelemetry::Trace::SpanContext.new(trace_id: trace_id, trace_flags: trace_flags, tracestate: tracestate)
56
+ context = OpenTelemetry::Trace::SpanContext.new(trace_id: trace_id, trace_flags: trace_flags, tracestate: result.tracestate)
57
57
  attributes = attributes&.merge(result.attributes) || result.attributes
58
58
  Span.new(
59
59
  context,
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2019 OpenTelemetry Authors
3
+ # Copyright The OpenTelemetry Authors
4
4
  #
5
5
  # SPDX-License-Identifier: Apache-2.0
6
6
 
@@ -49,13 +49,15 @@ module OpenTelemetry
49
49
  # processed and exported.
50
50
  #
51
51
  # After this is called all the newly created {Span}s will be no-op.
52
- def shutdown
52
+ #
53
+ # @param [optional Numeric] timeout An optional timeout in seconds.
54
+ def shutdown(timeout: nil)
53
55
  @mutex.synchronize do
54
56
  if @stopped
55
57
  OpenTelemetry.logger.warn('calling Tracer#shutdown multiple times.')
56
58
  return
57
59
  end
58
- @active_span_processor.shutdown
60
+ @active_span_processor.shutdown(timeout: timeout)
59
61
  @stopped = true
60
62
  end
61
63
  end
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2019 OpenTelemetry Authors
3
+ # Copyright The OpenTelemetry Authors
4
4
  #
5
5
  # SPDX-License-Identifier: Apache-2.0
6
6
 
7
7
  module OpenTelemetry
8
8
  module SDK
9
9
  ## Current OpenTelemetry version
10
- VERSION = '0.7.0'
10
+ VERSION = '0.11.1'
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: 0.7.0
4
+ version: 0.11.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: 2020-10-08 00:00:00.000000000 Z
11
+ date: 2020-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opentelemetry-api
@@ -16,14 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.7.0
19
+ version: 0.11.0
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: 0.7.0
26
+ version: 0.11.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: opentelemetry-common
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.11.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.11.0
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -166,6 +180,7 @@ files:
166
180
  - lib/opentelemetry/sdk/trace/export/batch_span_processor.rb
167
181
  - lib/opentelemetry/sdk/trace/export/console_span_exporter.rb
168
182
  - lib/opentelemetry/sdk/trace/export/in_memory_span_exporter.rb
183
+ - lib/opentelemetry/sdk/trace/export/metrics_reporter.rb
169
184
  - lib/opentelemetry/sdk/trace/export/multi_span_exporter.rb
170
185
  - lib/opentelemetry/sdk/trace/export/noop_span_exporter.rb
171
186
  - lib/opentelemetry/sdk/trace/export/simple_span_processor.rb
@@ -185,7 +200,11 @@ files:
185
200
  homepage: https://github.com/open-telemetry/opentelemetry-ruby
186
201
  licenses:
187
202
  - Apache-2.0
188
- metadata: {}
203
+ metadata:
204
+ changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk/v0.11.1/file.CHANGELOG.html
205
+ source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/master/sdk
206
+ bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby/issues
207
+ documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk/v0.11.1
189
208
  post_install_message:
190
209
  rdoc_options: []
191
210
  require_paths: