opentelemetry-sdk 0.8.0 → 0.12.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 +35 -0
- data/LICENSE +1 -1
- data/lib/opentelemetry-sdk.rb +1 -1
- data/lib/opentelemetry/sdk.rb +13 -1
- data/lib/opentelemetry/sdk/baggage.rb +1 -1
- data/lib/opentelemetry/sdk/baggage/builder.rb +1 -1
- data/lib/opentelemetry/sdk/baggage/manager.rb +1 -1
- data/lib/opentelemetry/sdk/configurator.rb +9 -2
- data/lib/opentelemetry/sdk/instrumentation_library.rb +1 -1
- data/lib/opentelemetry/sdk/internal.rb +12 -2
- data/lib/opentelemetry/sdk/resources.rb +1 -1
- data/lib/opentelemetry/sdk/resources/constants.rb +1 -1
- data/lib/opentelemetry/sdk/resources/resource.rb +2 -2
- data/lib/opentelemetry/sdk/trace.rb +1 -1
- data/lib/opentelemetry/sdk/trace/config.rb +1 -1
- data/lib/opentelemetry/sdk/trace/config/trace_config.rb +23 -21
- data/lib/opentelemetry/sdk/trace/event.rb +1 -1
- data/lib/opentelemetry/sdk/trace/export.rb +2 -1
- data/lib/opentelemetry/sdk/trace/export/batch_span_processor.rb +67 -30
- data/lib/opentelemetry/sdk/trace/export/console_span_exporter.rb +3 -3
- data/lib/opentelemetry/sdk/trace/export/in_memory_span_exporter.rb +5 -3
- data/lib/opentelemetry/sdk/trace/export/metrics_reporter.rb +59 -0
- data/lib/opentelemetry/sdk/trace/export/multi_span_exporter.rb +15 -17
- data/lib/opentelemetry/sdk/trace/export/noop_span_exporter.rb +6 -3
- data/lib/opentelemetry/sdk/trace/export/simple_span_processor.rb +13 -5
- data/lib/opentelemetry/sdk/trace/multi_span_processor.rb +21 -5
- data/lib/opentelemetry/sdk/trace/noop_span_processor.rb +5 -3
- data/lib/opentelemetry/sdk/trace/samplers.rb +7 -13
- data/lib/opentelemetry/sdk/trace/samplers/constant_sampler.rb +12 -5
- data/lib/opentelemetry/sdk/trace/samplers/decision.rb +1 -1
- data/lib/opentelemetry/sdk/trace/samplers/parent_based.rb +17 -4
- data/lib/opentelemetry/sdk/trace/samplers/result.rb +14 -3
- data/lib/opentelemetry/sdk/trace/samplers/trace_id_ratio_based.rb +8 -5
- data/lib/opentelemetry/sdk/trace/span.rb +12 -7
- data/lib/opentelemetry/sdk/trace/span_data.rb +1 -1
- data/lib/opentelemetry/sdk/trace/tracer.rb +9 -11
- data/lib/opentelemetry/sdk/trace/tracer_provider.rb +7 -4
- data/lib/opentelemetry/sdk/version.rb +2 -2
- metadata +21 -6
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright
|
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
|
-
|
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
|
3
|
+
# Copyright The OpenTelemetry Authors
|
4
4
|
#
|
5
5
|
# SPDX-License-Identifier: Apache-2.0
|
6
6
|
|
@@ -20,16 +20,19 @@ module OpenTelemetry
|
|
20
20
|
@description = format('TraceIdRatioBased{%.6f}', probability)
|
21
21
|
end
|
22
22
|
|
23
|
+
def ==(other)
|
24
|
+
@description == other.description
|
25
|
+
end
|
26
|
+
|
23
27
|
# @api private
|
24
28
|
#
|
25
29
|
# See {Samplers}.
|
26
30
|
def should_sample?(trace_id:, parent_context:, links:, name:, kind:, attributes:)
|
27
|
-
|
28
|
-
|
31
|
+
tracestate = OpenTelemetry::Trace.current_span(parent_context).context.tracestate
|
29
32
|
if sample?(trace_id)
|
30
|
-
RECORD_AND_SAMPLE
|
33
|
+
Result.new(decision: Decision::RECORD_AND_SAMPLE, tracestate: tracestate)
|
31
34
|
else
|
32
|
-
DROP
|
35
|
+
Result.new(decision: Decision::DROP, tracestate: tracestate)
|
33
36
|
end
|
34
37
|
end
|
35
38
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright
|
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
|
-
|
55
|
+
!@ended
|
56
56
|
end
|
57
57
|
|
58
58
|
# Set attribute
|
@@ -199,7 +199,7 @@ module OpenTelemetry
|
|
199
199
|
return self
|
200
200
|
end
|
201
201
|
@end_timestamp = end_timestamp || Time.now
|
202
|
-
@attributes.freeze
|
202
|
+
@attributes = validated_attributes(@attributes).freeze
|
203
203
|
@events.freeze
|
204
204
|
@ended = true
|
205
205
|
end
|
@@ -269,12 +269,16 @@ module OpenTelemetry
|
|
269
269
|
|
270
270
|
private
|
271
271
|
|
272
|
+
def validated_attributes(attrs)
|
273
|
+
return attrs if Internal.valid_attributes?(attrs)
|
274
|
+
|
275
|
+
attrs.keep_if { |key, value| Internal.valid_key?(key) && Internal.valid_value?(value) }
|
276
|
+
end
|
277
|
+
|
272
278
|
def trim_span_attributes(attrs)
|
273
279
|
return if attrs.nil?
|
274
280
|
|
275
281
|
excess = attrs.size - @trace_config.max_attributes_count
|
276
|
-
# TODO: with Ruby 2.5, replace with the more efficient
|
277
|
-
# attrs.shift(excess) if excess.positive?
|
278
282
|
excess.times { attrs.shift } if excess.positive?
|
279
283
|
nil
|
280
284
|
end
|
@@ -301,11 +305,12 @@ module OpenTelemetry
|
|
301
305
|
def append_event(events, event) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
302
306
|
max_events_count = @trace_config.max_events_count
|
303
307
|
max_attributes_per_event = @trace_config.max_attributes_per_event
|
308
|
+
valid_attributes = Internal.valid_attributes?(event.attributes)
|
304
309
|
|
305
310
|
# Fast path (likely) common case.
|
306
311
|
if events.size < max_events_count &&
|
307
312
|
event.attributes.size <= max_attributes_per_event &&
|
308
|
-
|
313
|
+
valid_attributes
|
309
314
|
return events << event
|
310
315
|
end
|
311
316
|
|
@@ -314,7 +319,7 @@ module OpenTelemetry
|
|
314
319
|
events.shift(excess) if excess.positive?
|
315
320
|
|
316
321
|
excess = event.attributes.size - max_attributes_per_event
|
317
|
-
if excess.positive? || !
|
322
|
+
if excess.positive? || !valid_attributes
|
318
323
|
attrs = Hash[event.attributes] # event.attributes is frozen, so we need an unfrozen copy to adjust.
|
319
324
|
attrs.keep_if { |key, value| Internal.valid_key?(key) && Internal.valid_value?(value) }
|
320
325
|
excess = attrs.size - max_attributes_per_event
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright
|
3
|
+
# Copyright The OpenTelemetry Authors
|
4
4
|
#
|
5
5
|
# SPDX-License-Identifier: Apache-2.0
|
6
6
|
|
@@ -33,30 +33,28 @@ 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
|
40
40
|
parent_span_context = OpenTelemetry::Trace.current_span(with_parent).context
|
41
41
|
if parent_span_context.valid?
|
42
42
|
parent_span_id = parent_span_context.span_id
|
43
|
-
tracestate = parent_span_context.tracestate
|
44
43
|
trace_id = parent_span_context.trace_id
|
45
|
-
else
|
46
|
-
parent_span_context = nil
|
47
44
|
end
|
48
|
-
trace_id ||=
|
45
|
+
trace_id ||= tracer_provider.id_generator.generate_trace_id
|
49
46
|
sampler = tracer_provider.active_trace_config.sampler
|
50
|
-
result = sampler.should_sample?(trace_id: trace_id, parent_context:
|
51
|
-
internal_create_span(result, name, kind, trace_id, parent_span_id, attributes, links, start_timestamp,
|
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)
|
52
49
|
end
|
53
50
|
|
54
51
|
private
|
55
52
|
|
56
|
-
def internal_create_span(result, name, kind, trace_id, parent_span_id, attributes, links, start_timestamp,
|
53
|
+
def internal_create_span(result, name, kind, trace_id, parent_span_id, attributes, links, start_timestamp, parent_context) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
54
|
+
span_id = tracer_provider.id_generator.generate_span_id
|
57
55
|
if result.recording? && !tracer_provider.stopped?
|
58
56
|
trace_flags = result.sampled? ? OpenTelemetry::Trace::TraceFlags::SAMPLED : OpenTelemetry::Trace::TraceFlags::DEFAULT
|
59
|
-
context = OpenTelemetry::Trace::SpanContext.new(trace_id: trace_id, trace_flags: trace_flags, tracestate: tracestate)
|
57
|
+
context = OpenTelemetry::Trace::SpanContext.new(trace_id: trace_id, span_id: span_id, trace_flags: trace_flags, tracestate: result.tracestate)
|
60
58
|
attributes = attributes&.merge(result.attributes) || result.attributes
|
61
59
|
Span.new(
|
62
60
|
context,
|
@@ -73,7 +71,7 @@ module OpenTelemetry
|
|
73
71
|
@instrumentation_library
|
74
72
|
)
|
75
73
|
else
|
76
|
-
OpenTelemetry::Trace::Span.new(span_context: OpenTelemetry::Trace::SpanContext.new(trace_id: trace_id))
|
74
|
+
OpenTelemetry::Trace::Span.new(span_context: OpenTelemetry::Trace::SpanContext.new(trace_id: trace_id, span_id: span_id, tracestate: result.tracestate))
|
77
75
|
end
|
78
76
|
end
|
79
77
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright
|
3
|
+
# Copyright The OpenTelemetry Authors
|
4
4
|
#
|
5
5
|
# SPDX-License-Identifier: Apache-2.0
|
6
6
|
|
@@ -12,7 +12,7 @@ module OpenTelemetry
|
|
12
12
|
Key = Struct.new(:name, :version)
|
13
13
|
private_constant(:Key)
|
14
14
|
|
15
|
-
attr_accessor :active_trace_config
|
15
|
+
attr_accessor :active_trace_config, :id_generator
|
16
16
|
attr_reader :active_span_processor, :stopped, :resource
|
17
17
|
alias stopped? stopped
|
18
18
|
|
@@ -24,6 +24,7 @@ module OpenTelemetry
|
|
24
24
|
@registry = {}
|
25
25
|
@active_span_processor = NoopSpanProcessor.instance
|
26
26
|
@active_trace_config = Config::TraceConfig::DEFAULT
|
27
|
+
@id_generator = OpenTelemetry::Trace
|
27
28
|
@registered_span_processors = []
|
28
29
|
@stopped = false
|
29
30
|
@resource = resource
|
@@ -49,13 +50,15 @@ module OpenTelemetry
|
|
49
50
|
# processed and exported.
|
50
51
|
#
|
51
52
|
# After this is called all the newly created {Span}s will be no-op.
|
52
|
-
|
53
|
+
#
|
54
|
+
# @param [optional Numeric] timeout An optional timeout in seconds.
|
55
|
+
def shutdown(timeout: nil)
|
53
56
|
@mutex.synchronize do
|
54
57
|
if @stopped
|
55
58
|
OpenTelemetry.logger.warn('calling Tracer#shutdown multiple times.')
|
56
59
|
return
|
57
60
|
end
|
58
|
-
@active_span_processor.shutdown
|
61
|
+
@active_span_processor.shutdown(timeout: timeout)
|
59
62
|
@stopped = true
|
60
63
|
end
|
61
64
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright
|
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.
|
10
|
+
VERSION = '0.12.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: 0.
|
4
|
+
version: 0.12.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-12-24 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.12.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.12.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.12.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.12.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
|
@@ -186,10 +201,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby
|
|
186
201
|
licenses:
|
187
202
|
- Apache-2.0
|
188
203
|
metadata:
|
189
|
-
changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk/v0.
|
204
|
+
changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk/v0.12.0/file.CHANGELOG.html
|
190
205
|
source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/master/sdk
|
191
206
|
bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby/issues
|
192
|
-
documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk/v0.
|
207
|
+
documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk/v0.12.0
|
193
208
|
post_install_message:
|
194
209
|
rdoc_options: []
|
195
210
|
require_paths:
|