opentelemetry-sdk 0.8.0 → 0.9.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 +4 -4
- data/CHANGELOG.md +12 -0
- data/lib/opentelemetry/sdk.rb +1 -0
- data/lib/opentelemetry/sdk/trace/export/batch_span_processor.rb +41 -27
- data/lib/opentelemetry/sdk/trace/export/console_span_exporter.rb +2 -2
- data/lib/opentelemetry/sdk/trace/export/in_memory_span_exporter.rb +4 -2
- data/lib/opentelemetry/sdk/trace/export/multi_span_exporter.rb +14 -16
- data/lib/opentelemetry/sdk/trace/export/noop_span_exporter.rb +5 -2
- data/lib/opentelemetry/sdk/trace/export/simple_span_processor.rb +11 -3
- data/lib/opentelemetry/sdk/trace/multi_span_processor.rb +20 -4
- data/lib/opentelemetry/sdk/trace/noop_span_processor.rb +4 -2
- data/lib/opentelemetry/sdk/trace/samplers.rb +4 -3
- data/lib/opentelemetry/sdk/trace/samplers/parent_based.rb +5 -4
- data/lib/opentelemetry/sdk/trace/span.rb +1 -1
- data/lib/opentelemetry/sdk/trace/tracer.rb +2 -4
- data/lib/opentelemetry/sdk/trace/tracer_provider.rb +4 -2
- data/lib/opentelemetry/sdk/version.rb +1 -1
- metadata +20 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92bb8c4a7792c37eb367fc10a3093b3fe27339592bc8689cdac308f21ba8ffa7
|
4
|
+
data.tar.gz: 2a0b6df150bbf2cb0987d1d4e5aa29fb37323bb740786ee2171e3ae037ff60ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59acf74f4d8cd4d4b1b7206690b6b0ddff389e98a76d151eb3cc08b97168af5c876a67a537123d81f2a3c7e65e3d52aea07f502bff02b7f8736863c8d299587e
|
7
|
+
data.tar.gz: b99ebe6b214387d35d530d01d154f017cb5ae9ea11f6922773c12d1b2fa2807a1051d5d3f021816ad6970d152794ccb1b2e9af37c46b5fde768d4c8574d8833b
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# Release History: opentelemetry-sdk
|
2
2
|
|
3
|
+
### v0.9.0 / 2020-11-27
|
4
|
+
|
5
|
+
* BREAKING CHANGE: Pass full Context to samplers
|
6
|
+
* BREAKING CHANGE: Add timeout for force_flush and shutdown
|
7
|
+
|
8
|
+
* ADDED: Add OTEL_RUBY_BSP_START_THREAD_ON_BOOT env var
|
9
|
+
* ADDED: Add timeout for force_flush and shutdown
|
10
|
+
* FIXED: Signal at batch_size
|
11
|
+
* FIXED: SDK Span.recording? after finish
|
12
|
+
* FIXED: Pass full Context to samplers
|
13
|
+
* DOCS: Add documentation on usage scenarios for span processors
|
14
|
+
|
3
15
|
### v0.8.0 / 2020-10-27
|
4
16
|
|
5
17
|
* BREAKING CHANGE: Move context/span methods to Trace module
|
data/lib/opentelemetry/sdk.rb
CHANGED
@@ -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,12 +47,14 @@ 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)
|
48
52
|
raise ArgumentError if max_export_batch_size > max_queue_size
|
49
53
|
|
50
54
|
@exporter = exporter
|
51
55
|
@exporter_timeout_seconds = exporter_timeout_millis / 1000.0
|
52
56
|
@mutex = Mutex.new
|
57
|
+
@export_mutex = Mutex.new
|
53
58
|
@condition = ConditionVariable.new
|
54
59
|
@keep_running = true
|
55
60
|
@delay_seconds = schedule_delay_millis / 1000.0
|
@@ -58,15 +63,13 @@ module OpenTelemetry
|
|
58
63
|
@spans = []
|
59
64
|
@pid = nil
|
60
65
|
@thread = nil
|
61
|
-
reset_on_fork
|
66
|
+
reset_on_fork(restart_thread: start_thread_on_boot)
|
62
67
|
end
|
63
68
|
|
64
|
-
#
|
65
|
-
def on_start(
|
66
|
-
# noop
|
67
|
-
end
|
69
|
+
# Does nothing for this processor
|
70
|
+
def on_start(_span, _parent_context); end
|
68
71
|
|
69
|
-
#
|
72
|
+
# Adds a span to the batch. Thread-safe; may block on lock.
|
70
73
|
def on_finish(span) # rubocop:disable Metrics/AbcSize
|
71
74
|
return unless span.context.trace_flags.sampled?
|
72
75
|
|
@@ -75,11 +78,10 @@ module OpenTelemetry
|
|
75
78
|
n = spans.size + 1 - max_queue_size
|
76
79
|
spans.shift(n) if n.positive?
|
77
80
|
spans << span
|
78
|
-
@condition.signal if spans.size >
|
81
|
+
@condition.signal if spans.size > batch_size
|
79
82
|
end
|
80
83
|
end
|
81
84
|
|
82
|
-
# TODO: test this explicitly.
|
83
85
|
# Export all ended spans to the configured `Exporter` that have not yet
|
84
86
|
# been exported.
|
85
87
|
#
|
@@ -88,35 +90,52 @@ module OpenTelemetry
|
|
88
90
|
# the process after an invocation, but before the `Processor` exports
|
89
91
|
# the completed spans.
|
90
92
|
#
|
93
|
+
# @param [optional Numeric] timeout An optional timeout in seconds.
|
91
94
|
# @return [Integer] SUCCESS if no error occurred, FAILURE if a
|
92
95
|
# non-specific failure occurred, TIMEOUT if a timeout occurred.
|
93
|
-
def force_flush
|
96
|
+
def force_flush(timeout: nil) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
97
|
+
start_time = Time.now
|
94
98
|
snapshot = lock do
|
95
99
|
reset_on_fork(restart_thread: false) if @keep_running
|
96
100
|
spans.shift(spans.size)
|
97
101
|
end
|
98
102
|
until snapshot.empty?
|
103
|
+
remaining_timeout = OpenTelemetry::Common::Utilities.maybe_timeout(timeout, start_time)
|
104
|
+
return TIMEOUT if remaining_timeout&.zero?
|
105
|
+
|
99
106
|
batch = snapshot.shift(@batch_size).map!(&:to_span_data)
|
100
|
-
result_code =
|
101
|
-
|
107
|
+
result_code = export_batch(batch, timeout: remaining_timeout)
|
108
|
+
return result_code unless result_code == SUCCESS
|
102
109
|
end
|
110
|
+
|
103
111
|
SUCCESS
|
112
|
+
ensure
|
113
|
+
# Unshift the remaining spans if we timed out. We drop excess spans from
|
114
|
+
# the snapshot because they're older than any spans in the spans buffer.
|
115
|
+
lock do
|
116
|
+
n = spans.size + snapshot.size - max_queue_size
|
117
|
+
snapshot.shift(n) if n.positive?
|
118
|
+
spans.unshift(snapshot) unless snapshot.empty?
|
119
|
+
@condition.signal if spans.size > max_queue_size / 2
|
120
|
+
end
|
104
121
|
end
|
105
122
|
|
106
|
-
#
|
107
|
-
# will block until the thread is finished
|
123
|
+
# Shuts the consumer thread down and flushes the current accumulated buffer
|
124
|
+
# will block until the thread is finished.
|
108
125
|
#
|
126
|
+
# @param [optional Numeric] timeout An optional timeout in seconds.
|
109
127
|
# @return [Integer] SUCCESS if no error occurred, FAILURE if a
|
110
128
|
# non-specific failure occurred, TIMEOUT if a timeout occurred.
|
111
|
-
def shutdown
|
129
|
+
def shutdown(timeout: nil)
|
130
|
+
start_time = Time.now
|
112
131
|
lock do
|
113
132
|
@keep_running = false
|
114
133
|
@condition.signal
|
115
134
|
end
|
116
135
|
|
117
|
-
@thread.join
|
118
|
-
force_flush
|
119
|
-
@exporter.shutdown
|
136
|
+
@thread.join(timeout)
|
137
|
+
force_flush(timeout: OpenTelemetry::Common::Utilities.maybe_timeout(timeout, start_time))
|
138
|
+
@exporter.shutdown(timeout: OpenTelemetry::Common::Utilities.maybe_timeout(timeout, start_time))
|
120
139
|
end
|
121
140
|
|
122
141
|
private
|
@@ -147,15 +166,10 @@ module OpenTelemetry
|
|
147
166
|
@thread = Thread.new { work } if restart_thread
|
148
167
|
end
|
149
168
|
|
150
|
-
def export_batch(batch)
|
151
|
-
result_code =
|
169
|
+
def export_batch(batch, timeout: @exporter_timeout_seconds)
|
170
|
+
result_code = @export_mutex.synchronize { @exporter.export(batch, timeout: timeout) }
|
152
171
|
report_result(result_code, batch)
|
153
|
-
|
154
|
-
|
155
|
-
def export_with_timeout(batch)
|
156
|
-
Timeout.timeout(@exporter_timeout_seconds) { @exporter.export(batch) }
|
157
|
-
rescue Timeout::Error
|
158
|
-
FAILURE
|
172
|
+
result_code
|
159
173
|
end
|
160
174
|
|
161
175
|
def report_result(result_code, batch)
|
@@ -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
|
@@ -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
|
@@ -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
|
-
|
29
|
-
|
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
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
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
|
-
|
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
|
@@ -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
|
-
|
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
|
@@ -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
|
@@ -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
|
-
|
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
|
-
|
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
|
@@ -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
|
@@ -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::
|
29
|
-
# {OpenTelemetry::
|
30
|
-
#
|
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,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
|
-
|
40
|
+
parent_span_context = OpenTelemetry::Trace.current_span(parent_context).context
|
41
|
+
delegate = if !parent_span_context.valid?
|
41
42
|
@root
|
42
|
-
elsif
|
43
|
-
|
43
|
+
elsif parent_span_context.remote?
|
44
|
+
parent_span_context.trace_flags.sampled? ? @remote_parent_sampled : @remote_parent_not_sampled
|
44
45
|
else
|
45
|
-
|
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
|
@@ -33,7 +33,7 @@ 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)
|
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
|
@@ -42,12 +42,10 @@ module OpenTelemetry
|
|
42
42
|
parent_span_id = parent_span_context.span_id
|
43
43
|
tracestate = parent_span_context.tracestate
|
44
44
|
trace_id = parent_span_context.trace_id
|
45
|
-
else
|
46
|
-
parent_span_context = nil
|
47
45
|
end
|
48
46
|
trace_id ||= OpenTelemetry::Trace.generate_trace_id
|
49
47
|
sampler = tracer_provider.active_trace_config.sampler
|
50
|
-
result = sampler.should_sample?(trace_id: trace_id, parent_context:
|
48
|
+
result = sampler.should_sample?(trace_id: trace_id, parent_context: with_parent, links: links, name: name, kind: kind, attributes: attributes)
|
51
49
|
internal_create_span(result, name, kind, trace_id, parent_span_id, attributes, links, start_timestamp, tracestate, with_parent)
|
52
50
|
end
|
53
51
|
|
@@ -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
|
-
|
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
|
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.
|
4
|
+
version: 0.9.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: 2020-
|
11
|
+
date: 2020-11-27 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.
|
19
|
+
version: 0.9.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.
|
26
|
+
version: 0.9.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.9.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.9.0
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -186,10 +200,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby
|
|
186
200
|
licenses:
|
187
201
|
- Apache-2.0
|
188
202
|
metadata:
|
189
|
-
changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk/v0.
|
203
|
+
changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk/v0.9.0/file.CHANGELOG.html
|
190
204
|
source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/master/sdk
|
191
205
|
bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby/issues
|
192
|
-
documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk/v0.
|
206
|
+
documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk/v0.9.0
|
193
207
|
post_install_message:
|
194
208
|
rdoc_options: []
|
195
209
|
require_paths:
|