opentelemetry-sdk 0.12.0 → 0.15.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 +38 -0
- data/README.md +2 -2
- data/lib/opentelemetry/sdk/configurator.rb +54 -44
- data/lib/opentelemetry/sdk/resources/constants.rb +40 -0
- data/lib/opentelemetry/sdk/resources/resource.rb +17 -5
- data/lib/opentelemetry/sdk/trace/config/trace_config.rb +6 -6
- data/lib/opentelemetry/sdk/trace/export/batch_span_processor.rb +20 -16
- data/lib/opentelemetry/sdk/trace/span.rb +16 -8
- data/lib/opentelemetry/sdk/trace/tracer_provider.rb +5 -6
- data/lib/opentelemetry/sdk/version.rb +1 -1
- metadata +23 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83141347c526da6e87b4858c6ad9277ec4d2a59a452944114f21618b86d98db1
|
4
|
+
data.tar.gz: e1ebac32ea8dbcbb5087bf2d06bae25f5ed269fb7a3e17159d37d41def7b5063
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68a19f8ce70e8a1dc00bcea801c16f405f86a826e9501a9e513fd0070adca7e8cbe51f958f6957f8d38bae768fa9f8b4b111c55112d95309bb0bcfb8b85c5e26
|
7
|
+
data.tar.gz: a25e070825c5d2f886e01c8b1659e63f73810fbae89ac629c4e5b2319391c859db90b87901d294044fc06e8f4bb7879e97ce3549484d408695f7aac0345c1256
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,43 @@
|
|
1
1
|
# Release History: opentelemetry-sdk
|
2
2
|
|
3
|
+
### v0.15.0 / 2021-02-18
|
4
|
+
|
5
|
+
* BREAKING CHANGE: Streamline processor pipeline
|
6
|
+
|
7
|
+
* ADDED: Add instrumentation config validation
|
8
|
+
* FIXED: Streamline processor pipeline
|
9
|
+
* FIXED: OTEL_TRACE -> OTEL_TRACES env vars
|
10
|
+
* FIXED: Change limits from 1000 to 128
|
11
|
+
* FIXED: OTEL_TRACES_EXPORTER and OTEL_PROPAGATORS
|
12
|
+
* FIXED: Add thread error handling to the BSP
|
13
|
+
* DOCS: Clarify nil attribute values not allowed
|
14
|
+
|
15
|
+
### v0.14.0 / 2021-02-03
|
16
|
+
|
17
|
+
* BREAKING CHANGE: Replace getter and setter callables and remove rack specific propagators
|
18
|
+
|
19
|
+
* ADDED: Replace getter and setter callables and remove rack specific propagators
|
20
|
+
|
21
|
+
### v0.13.1 / 2021-02-01
|
22
|
+
|
23
|
+
* FIXED: Leaky test
|
24
|
+
* FIXED: Allow env var override of service.name
|
25
|
+
|
26
|
+
### v0.13.0 / 2021-01-29
|
27
|
+
|
28
|
+
* BREAKING CHANGE: Remove MILLIS from BatchSpanProcessor vars
|
29
|
+
|
30
|
+
* ADDED: Process.runtime resource
|
31
|
+
* ADDED: Provide default resource in SDK
|
32
|
+
* ADDED: Add optional attributes to record_exception
|
33
|
+
* FIXED: Resource.merge consistency
|
34
|
+
* FIXED: Remove MILLIS from BatchSpanProcessor vars
|
35
|
+
|
36
|
+
### v0.12.1 / 2021-01-13
|
37
|
+
|
38
|
+
* FIXED: Fix several BatchSpanProcessor errors related to fork safety
|
39
|
+
* FIXED: Define default value for traceid ratio
|
40
|
+
|
3
41
|
### v0.12.0 / 2020-12-24
|
4
42
|
|
5
43
|
* ADDED: Structured error handling
|
data/README.md
CHANGED
@@ -66,8 +66,8 @@ The `opentelemetry-sdk` gem is distributed under the Apache 2.0 license. See [LI
|
|
66
66
|
[opentelemetry-home]: https://opentelemetry.io
|
67
67
|
[bundler-home]: https://bundler.io
|
68
68
|
[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby
|
69
|
-
[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/
|
70
|
-
[examples-github]: https://github.com/open-telemetry/opentelemetry-ruby/tree/
|
69
|
+
[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE
|
70
|
+
[examples-github]: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/examples
|
71
71
|
[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig
|
72
72
|
[community-meetings]: https://github.com/open-telemetry/community#community-meetings
|
73
73
|
[ruby-gitter]: https://gitter.im/open-telemetry/opentelemetry-ruby
|
@@ -15,19 +15,17 @@ module OpenTelemetry
|
|
15
15
|
|
16
16
|
private_constant :USE_MODE_UNSPECIFIED, :USE_MODE_ONE, :USE_MODE_ALL
|
17
17
|
|
18
|
-
attr_writer :logger, :
|
19
|
-
:
|
18
|
+
attr_writer :logger, :extractors, :injectors, :error_handler,
|
19
|
+
:id_generator
|
20
20
|
|
21
21
|
def initialize
|
22
22
|
@instrumentation_names = []
|
23
23
|
@instrumentation_config_map = {}
|
24
|
-
@
|
25
|
-
@
|
26
|
-
@text_map_extractors = nil
|
27
|
-
@text_map_injectors = nil
|
24
|
+
@injectors = nil
|
25
|
+
@extractors = nil
|
28
26
|
@span_processors = []
|
29
27
|
@use_mode = USE_MODE_UNSPECIFIED
|
30
|
-
@resource = Resources::Resource.
|
28
|
+
@resource = Resources::Resource.default
|
31
29
|
@id_generator = OpenTelemetry::Trace
|
32
30
|
end
|
33
31
|
|
@@ -46,7 +44,7 @@ module OpenTelemetry
|
|
46
44
|
#
|
47
45
|
# @param [Resource] new_resource The resource to be merged
|
48
46
|
def resource=(new_resource)
|
49
|
-
@resource =
|
47
|
+
@resource = @resource.merge(new_resource)
|
50
48
|
end
|
51
49
|
|
52
50
|
# Accepts a string that is merged in as the service.name resource attribute.
|
@@ -54,9 +52,9 @@ module OpenTelemetry
|
|
54
52
|
# calls to this setter.
|
55
53
|
# @param [String] service_name The value to be used as the service name
|
56
54
|
def service_name=(service_name)
|
57
|
-
|
55
|
+
self.resource = OpenTelemetry::SDK::Resources::Resource.create(
|
58
56
|
OpenTelemetry::SDK::Resources::Constants::SERVICE_RESOURCE[:name] => service_name
|
59
|
-
)
|
57
|
+
)
|
60
58
|
end
|
61
59
|
|
62
60
|
# Accepts a string that is merged in as the service.version resource attribute.
|
@@ -64,9 +62,9 @@ module OpenTelemetry
|
|
64
62
|
# calls to this setter.
|
65
63
|
# @param [String] service_version The value to be used as the service version
|
66
64
|
def service_version=(service_version)
|
67
|
-
|
65
|
+
self.resource = OpenTelemetry::SDK::Resources::Resource.create(
|
68
66
|
OpenTelemetry::SDK::Resources::Constants::SERVICE_RESOURCE[:version] => service_version
|
69
|
-
)
|
67
|
+
)
|
70
68
|
end
|
71
69
|
|
72
70
|
# Install an instrumentation with specificied optional +config+.
|
@@ -145,54 +143,66 @@ module OpenTelemetry
|
|
145
143
|
end
|
146
144
|
|
147
145
|
def configure_span_processors
|
148
|
-
processors = @span_processors.empty? ? [
|
146
|
+
processors = @span_processors.empty? ? [wrapped_exporter_from_env].compact : @span_processors
|
149
147
|
processors.each { |p| tracer_provider.add_span_processor(p) }
|
150
148
|
end
|
151
149
|
|
152
|
-
def
|
153
|
-
|
154
|
-
|
155
|
-
|
150
|
+
def wrapped_exporter_from_env
|
151
|
+
exporter = ENV.fetch('OTEL_TRACES_EXPORTER', 'otlp')
|
152
|
+
case exporter
|
153
|
+
when 'none' then nil
|
154
|
+
when 'otlp' then fetch_exporter(exporter, 'OpenTelemetry::Exporter::OTLP::Exporter')
|
155
|
+
when 'jaeger' then fetch_exporter(exporter, 'OpenTelemetry::Exporter::Jaeger::CollectorExporter')
|
156
|
+
when 'zipkin' then fetch_exporter(exporter, 'OpenTelemetry::Exporter::Zipkin::Exporter')
|
157
|
+
else
|
158
|
+
OpenTelemetry.logger.warn "The #{exporter} exporter is unknown and cannot be configured, spans will not be exported"
|
159
|
+
nil
|
160
|
+
end
|
156
161
|
end
|
157
162
|
|
158
|
-
def configure_propagation
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
+
def configure_propagation # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
|
164
|
+
propagators = ENV.fetch('OTEL_PROPAGATORS', 'tracecontext,baggage').split(',')
|
165
|
+
injectors, extractors = propagators.uniq.collect do |propagator|
|
166
|
+
case propagator
|
167
|
+
when 'tracecontext'
|
168
|
+
[OpenTelemetry::Trace::Propagation::TraceContext.text_map_injector, OpenTelemetry::Trace::Propagation::TraceContext.text_map_extractor]
|
169
|
+
when 'baggage'
|
170
|
+
[OpenTelemetry::Baggage::Propagation.text_map_injector, OpenTelemetry::Baggage::Propagation.text_map_extractor]
|
171
|
+
when 'b3' then fetch_propagator(propagator, 'OpenTelemetry::Propagator::B3::Single')
|
172
|
+
when 'b3multi' then fetch_propagator(propagator, 'OpenTelemetry::Propagator::B3::Multi', 'b3')
|
173
|
+
when 'jaeger' then fetch_propagator(propagator, 'OpenTelemetry::Propagator::Jaeger')
|
174
|
+
when 'xray' then fetch_propagator(propagator, 'OpenTelemetry::Propagator::XRay')
|
175
|
+
when 'ottrace' then fetch_propagator(propagator, 'OpenTelemetry::Propagator::OTTrace')
|
176
|
+
else
|
177
|
+
OpenTelemetry.logger.warn "The #{propagator} propagator is unknown and cannot be configured"
|
178
|
+
[Context::Propagation::NoopInjector.new, Context::Propagation::NoopExtractor.new]
|
179
|
+
end
|
180
|
+
end.transpose
|
181
|
+
OpenTelemetry.propagation = create_propagator(@injectors || injectors.compact,
|
182
|
+
@extractors || extractors.compact)
|
163
183
|
end
|
164
184
|
|
165
185
|
def create_propagator(injectors, extractors)
|
166
186
|
if injectors.size > 1 || extractors.size > 1
|
167
187
|
Context::Propagation::CompositePropagator.new(injectors, extractors)
|
168
188
|
else
|
169
|
-
Context::Propagation::Propagator.new(injectors, extractors)
|
189
|
+
Context::Propagation::Propagator.new(injectors.first, extractors.first)
|
170
190
|
end
|
171
191
|
end
|
172
192
|
|
173
|
-
def
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
[
|
179
|
-
OpenTelemetry::Trace::Propagation::TraceContext.rack_extractor,
|
180
|
-
OpenTelemetry::Baggage::Propagation.rack_extractor
|
181
|
-
]
|
182
|
-
end
|
183
|
-
|
184
|
-
def default_text_map_injectors
|
185
|
-
[
|
186
|
-
OpenTelemetry::Trace::Propagation::TraceContext.text_map_injector,
|
187
|
-
OpenTelemetry::Baggage::Propagation.text_map_injector
|
188
|
-
]
|
193
|
+
def fetch_propagator(name, class_name, gem_suffix = name)
|
194
|
+
propagator_class = Kernel.const_get(class_name)
|
195
|
+
[propagator_class.text_map_injector, propagator_class.text_map_extractor]
|
196
|
+
rescue NameError
|
197
|
+
OpenTelemetry.logger.warn "The #{name} propagator cannot be configured - please add opentelemetry-propagator-#{gem_suffix} to your Gemfile"
|
198
|
+
[nil, nil]
|
189
199
|
end
|
190
200
|
|
191
|
-
def
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
201
|
+
def fetch_exporter(name, class_name)
|
202
|
+
Trace::Export::BatchSpanProcessor.new(Kernel.const_get(class_name).new)
|
203
|
+
rescue NameError
|
204
|
+
OpenTelemetry.logger.warn "The #{name} exporter cannot be configured - please add opentelemetry-exporter-#{name} to your Gemfile, spans will not be exported"
|
205
|
+
nil
|
196
206
|
end
|
197
207
|
end
|
198
208
|
end
|
@@ -77,6 +77,46 @@ module OpenTelemetry
|
|
77
77
|
deployment_name: 'k8s.deployment.name'
|
78
78
|
}.freeze
|
79
79
|
|
80
|
+
# Attributes defining an operating system process.
|
81
|
+
PROCESS_RESOURCE = {
|
82
|
+
# Process identifier (PID).
|
83
|
+
pid: 'process.pid',
|
84
|
+
|
85
|
+
# The name of the process executable.
|
86
|
+
executable_name: 'process.executable.name',
|
87
|
+
|
88
|
+
# The full path to the process executable.
|
89
|
+
executable_path: 'process.executable.path',
|
90
|
+
|
91
|
+
# The command used to launch the process (i.e. the command name).
|
92
|
+
command: 'process.command',
|
93
|
+
|
94
|
+
# The full command used to launch the process as a single string
|
95
|
+
# representing the full command.
|
96
|
+
command_line: 'process.command_line',
|
97
|
+
|
98
|
+
# All the command arguments (including the command/executable itself)
|
99
|
+
# as received by the process.
|
100
|
+
command_args: 'process.command_args',
|
101
|
+
|
102
|
+
# The username of the user that owns the process.
|
103
|
+
owner: 'process.owner'
|
104
|
+
}.freeze
|
105
|
+
|
106
|
+
# Attributes defining the single (language) runtime instance which is monitored.
|
107
|
+
PROCESS_RUNTIME_RESOURCE = {
|
108
|
+
# The name of the runtime of this process.
|
109
|
+
name: 'process.runtime.name',
|
110
|
+
|
111
|
+
# The version of the runtime of this process, as returned by the runtime
|
112
|
+
# without modification.
|
113
|
+
version: 'process.runtime.version',
|
114
|
+
|
115
|
+
# An additional description about the runtime of the process, for example
|
116
|
+
# a specific vendor customization of the runtime environment.
|
117
|
+
description: 'process.runtime.description'
|
118
|
+
}.freeze
|
119
|
+
|
80
120
|
# Attributes defining a computing instance (e.g. host).
|
81
121
|
HOST_RESOURCE = {
|
82
122
|
# Unique host id. For Cloud this must be the instance_id assigned by the
|
@@ -30,6 +30,10 @@ module OpenTelemetry
|
|
30
30
|
new(frozen_attributes)
|
31
31
|
end
|
32
32
|
|
33
|
+
def default
|
34
|
+
@default ||= create(Constants::SERVICE_RESOURCE[:name] => 'unknown_service').merge(process).merge(telemetry_sdk)
|
35
|
+
end
|
36
|
+
|
33
37
|
def telemetry_sdk
|
34
38
|
resource_attributes = {
|
35
39
|
Constants::TELEMETRY_SDK_RESOURCE[:name] => 'opentelemetry',
|
@@ -48,6 +52,18 @@ module OpenTelemetry
|
|
48
52
|
resource_attributes.delete_if { |_key, value| value.nil? || value.empty? }
|
49
53
|
create(resource_attributes)
|
50
54
|
end
|
55
|
+
|
56
|
+
def process
|
57
|
+
resource_attributes = {
|
58
|
+
Constants::PROCESS_RESOURCE[:pid] => Process.pid,
|
59
|
+
Constants::PROCESS_RESOURCE[:command] => $PROGRAM_NAME,
|
60
|
+
Constants::PROCESS_RUNTIME_RESOURCE[:name] => RUBY_ENGINE,
|
61
|
+
Constants::PROCESS_RUNTIME_RESOURCE[:version] => RUBY_VERSION,
|
62
|
+
Constants::PROCESS_RUNTIME_RESOURCE[:description] => RUBY_DESCRIPTION
|
63
|
+
}
|
64
|
+
|
65
|
+
create(resource_attributes)
|
66
|
+
end
|
51
67
|
end
|
52
68
|
|
53
69
|
# @api private
|
@@ -79,11 +95,7 @@ module OpenTelemetry
|
|
79
95
|
def merge(other)
|
80
96
|
return self unless other.is_a?(Resource)
|
81
97
|
|
82
|
-
|
83
|
-
old_v.empty? ? new_v : old_v
|
84
|
-
end
|
85
|
-
|
86
|
-
self.class.send(:new, merged_attributes.freeze)
|
98
|
+
self.class.send(:new, attributes.merge(other.attributes).freeze)
|
87
99
|
end
|
88
100
|
|
89
101
|
protected
|
@@ -33,9 +33,9 @@ module OpenTelemetry
|
|
33
33
|
# @return [TraceConfig] with the desired values.
|
34
34
|
# @raise [ArgumentError] if any of the max numbers are not positive.
|
35
35
|
def initialize(sampler: sampler_from_environment(Samplers.parent_based(root: Samplers::ALWAYS_ON)),
|
36
|
-
max_attributes_count: Integer(ENV.fetch('OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT',
|
37
|
-
max_events_count: Integer(ENV.fetch('OTEL_SPAN_EVENT_COUNT_LIMIT',
|
38
|
-
max_links_count: Integer(ENV.fetch('OTEL_SPAN_LINK_COUNT_LIMIT',
|
36
|
+
max_attributes_count: Integer(ENV.fetch('OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT', 128)),
|
37
|
+
max_events_count: Integer(ENV.fetch('OTEL_SPAN_EVENT_COUNT_LIMIT', 128)),
|
38
|
+
max_links_count: Integer(ENV.fetch('OTEL_SPAN_LINK_COUNT_LIMIT', 128)),
|
39
39
|
max_attributes_per_event: max_attributes_count,
|
40
40
|
max_attributes_per_link: max_attributes_count)
|
41
41
|
raise ArgumentError, 'max_attributes_count must be positive' unless max_attributes_count.positive?
|
@@ -56,13 +56,13 @@ module OpenTelemetry
|
|
56
56
|
private
|
57
57
|
|
58
58
|
def sampler_from_environment(default_sampler) # rubocop:disable Metrics/CyclomaticComplexity
|
59
|
-
case ENV['
|
59
|
+
case ENV['OTEL_TRACES_SAMPLER']
|
60
60
|
when 'always_on' then Samplers::ALWAYS_ON
|
61
61
|
when 'always_off' then Samplers::ALWAYS_OFF
|
62
|
-
when 'traceidratio' then Samplers.trace_id_ratio_based(Float(ENV
|
62
|
+
when 'traceidratio' then Samplers.trace_id_ratio_based(Float(ENV.fetch('OTEL_TRACES_SAMPLER_ARG', 1.0)))
|
63
63
|
when 'parentbased_always_on' then Samplers.parent_based(root: Samplers::ALWAYS_ON)
|
64
64
|
when 'parentbased_always_off' then Samplers.parent_based(root: Samplers::ALWAYS_OFF)
|
65
|
-
when 'parentbased_traceidratio' then Samplers.parent_based(root: Samplers.trace_id_ratio_based(Float(ENV
|
65
|
+
when 'parentbased_traceidratio' then Samplers.parent_based(root: Samplers.trace_id_ratio_based(Float(ENV.fetch('OTEL_TRACES_SAMPLER_ARG', 1.0))))
|
66
66
|
else default_sampler
|
67
67
|
end
|
68
68
|
rescue StandardError => e
|
@@ -19,7 +19,7 @@ module OpenTelemetry
|
|
19
19
|
# All spans reported by the SDK implementation are first added to a
|
20
20
|
# synchronized queue (with a {max_queue_size} maximum size, after the
|
21
21
|
# size is reached spans are dropped) and exported every
|
22
|
-
#
|
22
|
+
# schedule_delay to the exporter pipeline in batches of
|
23
23
|
# max_export_batch_size.
|
24
24
|
#
|
25
25
|
# If the queue gets half full a preemptive notification is sent to the
|
@@ -28,12 +28,13 @@ module OpenTelemetry
|
|
28
28
|
class BatchSpanProcessor # rubocop:disable Metrics/ClassLength
|
29
29
|
# Returns a new instance of the {BatchSpanProcessor}.
|
30
30
|
#
|
31
|
-
# @param [SpanExporter] exporter
|
32
|
-
#
|
33
|
-
#
|
31
|
+
# @param [SpanExporter] exporter the (duck type) SpanExporter to where the
|
32
|
+
# recorded Spans are pushed after batching.
|
33
|
+
# @param [Numeric] exporter_timeout the delay interval between two
|
34
|
+
# consecutive exports. Defaults to the value of the OTEL_BSP_EXPORT_TIMEOUT
|
34
35
|
# environment variable, if set, or 30,000 (30 seconds).
|
35
|
-
# @param [Numeric]
|
36
|
-
# Defaults to the value of the
|
36
|
+
# @param [Numeric] schedule_delay the maximum allowed time to export data.
|
37
|
+
# Defaults to the value of the OTEL_BSP_SCHEDULE_DELAY environment
|
37
38
|
# variable, if set, or 5,000 (5 seconds).
|
38
39
|
# @param [Integer] max_queue_size the maximum queue size in spans.
|
39
40
|
# Defaults to the value of the OTEL_BSP_MAX_QUEUE_SIZE environment
|
@@ -43,9 +44,9 @@ module OpenTelemetry
|
|
43
44
|
# variable, if set, or 512.
|
44
45
|
#
|
45
46
|
# @return a new instance of the {BatchSpanProcessor}.
|
46
|
-
def initialize(exporter
|
47
|
-
|
48
|
-
|
47
|
+
def initialize(exporter,
|
48
|
+
exporter_timeout: Float(ENV.fetch('OTEL_BSP_EXPORT_TIMEOUT', 30_000)),
|
49
|
+
schedule_delay: Float(ENV.fetch('OTEL_BSP_SCHEDULE_DELAY', 5_000)),
|
49
50
|
max_queue_size: Integer(ENV.fetch('OTEL_BSP_MAX_QUEUE_SIZE', 2048)),
|
50
51
|
max_export_batch_size: Integer(ENV.fetch('OTEL_BSP_MAX_EXPORT_BATCH_SIZE', 512)),
|
51
52
|
start_thread_on_boot: String(ENV['OTEL_RUBY_BSP_START_THREAD_ON_BOOT']) !~ /false/i,
|
@@ -53,12 +54,12 @@ module OpenTelemetry
|
|
53
54
|
raise ArgumentError if max_export_batch_size > max_queue_size
|
54
55
|
|
55
56
|
@exporter = exporter
|
56
|
-
@exporter_timeout_seconds =
|
57
|
+
@exporter_timeout_seconds = exporter_timeout / 1000.0
|
57
58
|
@mutex = Mutex.new
|
58
59
|
@export_mutex = Mutex.new
|
59
60
|
@condition = ConditionVariable.new
|
60
61
|
@keep_running = true
|
61
|
-
@delay_seconds =
|
62
|
+
@delay_seconds = schedule_delay / 1000.0
|
62
63
|
@max_queue_size = max_queue_size
|
63
64
|
@batch_size = max_export_batch_size
|
64
65
|
@metrics_reporter = metrics_reporter || OpenTelemetry::SDK::Trace::Export::MetricsReporter
|
@@ -101,7 +102,7 @@ module OpenTelemetry
|
|
101
102
|
def force_flush(timeout: nil) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength
|
102
103
|
start_time = Time.now
|
103
104
|
snapshot = lock do
|
104
|
-
reset_on_fork
|
105
|
+
reset_on_fork if @keep_running
|
105
106
|
spans.shift(spans.size)
|
106
107
|
end
|
107
108
|
until snapshot.empty?
|
@@ -136,12 +137,13 @@ module OpenTelemetry
|
|
136
137
|
# non-specific failure occurred, TIMEOUT if a timeout occurred.
|
137
138
|
def shutdown(timeout: nil)
|
138
139
|
start_time = Time.now
|
139
|
-
lock do
|
140
|
+
thread = lock do
|
140
141
|
@keep_running = false
|
141
142
|
@condition.signal
|
143
|
+
@thread
|
142
144
|
end
|
143
145
|
|
144
|
-
|
146
|
+
thread&.join(timeout)
|
145
147
|
force_flush(timeout: OpenTelemetry::Common::Utilities.maybe_timeout(timeout, start_time))
|
146
148
|
@exporter.shutdown(timeout: OpenTelemetry::Common::Utilities.maybe_timeout(timeout, start_time))
|
147
149
|
dropped_spans = lock { spans.size }
|
@@ -155,7 +157,6 @@ module OpenTelemetry
|
|
155
157
|
def work # rubocop:disable Metrics/AbcSize
|
156
158
|
loop do
|
157
159
|
batch = lock do
|
158
|
-
reset_on_fork(restart_thread: false)
|
159
160
|
@condition.wait(@mutex, @delay_seconds) if spans.size < batch_size && @keep_running
|
160
161
|
@condition.wait(@mutex, @delay_seconds) while spans.empty? && @keep_running
|
161
162
|
return unless @keep_running
|
@@ -175,7 +176,10 @@ module OpenTelemetry
|
|
175
176
|
|
176
177
|
@pid = pid
|
177
178
|
spans.clear
|
178
|
-
@thread = Thread.new { work }
|
179
|
+
@thread = restart_thread ? Thread.new { work } : nil
|
180
|
+
rescue ThreadError => e
|
181
|
+
@metrics_reporter.add_to_counter('otel.bsp.error', labels: { 'reason' => 'ThreadError' })
|
182
|
+
OpenTelemetry.handle_error(exception: e, message: 'unexpected error in BatchSpanProcessor#reset_on_fork')
|
179
183
|
end
|
180
184
|
|
181
185
|
def export_batch(batch, timeout: @exporter_timeout_seconds)
|
@@ -64,6 +64,9 @@ module OpenTelemetry
|
|
64
64
|
#
|
65
65
|
# @param [String] key
|
66
66
|
# @param [String, Boolean, Numeric, Array<String, Numeric, Boolean>] value
|
67
|
+
# Values must be non-nil and (array of) string, boolean or numeric type.
|
68
|
+
# Array values must not contain nil elements and all elements must be of
|
69
|
+
# the same basic type (string, numeric, boolean).
|
67
70
|
#
|
68
71
|
# @return [self] returns itself
|
69
72
|
def set_attribute(key, value)
|
@@ -96,7 +99,7 @@ module OpenTelemetry
|
|
96
99
|
# @param [String] name Name of the event.
|
97
100
|
# @param [optional Hash{String => String, Numeric, Boolean, Array<String, Numeric, Boolean>}] attributes
|
98
101
|
# One or more key:value pairs, where the keys must be strings and the
|
99
|
-
# values may be string, boolean or numeric type.
|
102
|
+
# values may be (array of) string, boolean or numeric type.
|
100
103
|
# @param [optional Time] timestamp Optional timestamp for the event.
|
101
104
|
#
|
102
105
|
# @return [self] returns itself
|
@@ -120,15 +123,20 @@ module OpenTelemetry
|
|
120
123
|
# can be recorded on a span.
|
121
124
|
#
|
122
125
|
# @param [Exception] exception The exception to be recorded
|
126
|
+
# @param [optional Hash{String => String, Numeric, Boolean, Array<String, Numeric, Boolean>}]
|
127
|
+
# attributes One or more key:value pairs, where the keys must be
|
128
|
+
# strings and the values may be (array of) string, boolean or numeric
|
129
|
+
# type.
|
123
130
|
#
|
124
131
|
# @return [void]
|
125
|
-
def record_exception(exception)
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
+
def record_exception(exception, attributes: nil)
|
133
|
+
event_attributes = {
|
134
|
+
'exception.type' => exception.class.to_s,
|
135
|
+
'exception.message' => exception.message,
|
136
|
+
'exception.stacktrace' => exception.full_message(highlight: false, order: :top)
|
137
|
+
}
|
138
|
+
event_attributes.merge!(attributes) unless attributes.nil?
|
139
|
+
add_event('exception', attributes: event_attributes)
|
132
140
|
end
|
133
141
|
|
134
142
|
# Sets the Status to the Span
|
@@ -65,11 +65,6 @@ module OpenTelemetry
|
|
65
65
|
|
66
66
|
# Adds a new SpanProcessor to this {Tracer}.
|
67
67
|
#
|
68
|
-
# Any registered processor causes overhead, consider to use an
|
69
|
-
# async/batch processor especially for span exporting, and export to
|
70
|
-
# multiple backends using the
|
71
|
-
# {io.opentelemetry.sdk.trace.export.MultiSpanExporter}.
|
72
|
-
#
|
73
68
|
# @param span_processor the new SpanProcessor to be added.
|
74
69
|
def add_span_processor(span_processor)
|
75
70
|
@mutex.synchronize do
|
@@ -78,7 +73,11 @@ module OpenTelemetry
|
|
78
73
|
return
|
79
74
|
end
|
80
75
|
@registered_span_processors << span_processor
|
81
|
-
@active_span_processor =
|
76
|
+
@active_span_processor = if @registered_span_processors.size == 1
|
77
|
+
span_processor
|
78
|
+
else
|
79
|
+
MultiSpanProcessor.new(@registered_span_processors.dup)
|
80
|
+
end
|
82
81
|
end
|
83
82
|
end
|
84
83
|
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.15.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:
|
11
|
+
date: 2021-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opentelemetry-api
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.15.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.15.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: opentelemetry-common
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.15.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
40
|
+
version: 0.15.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '5.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: opentelemetry-exporter-jaeger
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.15.0
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.15.0
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: rake
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -201,10 +215,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby
|
|
201
215
|
licenses:
|
202
216
|
- Apache-2.0
|
203
217
|
metadata:
|
204
|
-
changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk/v0.
|
205
|
-
source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/
|
218
|
+
changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk/v0.15.0/file.CHANGELOG.html
|
219
|
+
source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/sdk
|
206
220
|
bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby/issues
|
207
|
-
documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk/v0.
|
221
|
+
documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk/v0.15.0
|
208
222
|
post_install_message:
|
209
223
|
rdoc_options: []
|
210
224
|
require_paths:
|