opentelemetry-sdk 1.0.0 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -0
- data/lib/opentelemetry/sdk/configurator.rb +10 -2
- data/lib/opentelemetry/sdk/internal.rb +7 -3
- data/lib/opentelemetry/sdk/trace/export/batch_span_processor.rb +4 -0
- data/lib/opentelemetry/sdk/trace/span.rb +56 -9
- data/lib/opentelemetry/sdk/trace/span_limits.rb +2 -1
- data/lib/opentelemetry/sdk/trace/tracer.rb +3 -1
- data/lib/opentelemetry/sdk/trace/tracer_provider.rb +9 -1
- data/lib/opentelemetry/sdk/version.rb +1 -1
- metadata +22 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f49ca16dd123f2ab96a64ff6e9b5cf6c2e10af45ed433bea357f2cbe188a12bc
|
4
|
+
data.tar.gz: 8827826f4cf1abddd6b421fa8812decaacf92c9277877bb7a1e38aecaf8691dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 804969ec3b44d01fb66f5ffa1ee9390065f3652942596477fc9e61187472d018c965ee5f9311f277d2fe99ec4b07c4b880272447777431409b9a3eea8b045037
|
7
|
+
data.tar.gz: 589ff982bc7add6a30fca440143f5ea2ff94068de0bc8f5dd9ab5678c45e55ed96b41b65e53836878ed87fa6c82ed585db050f3ddf147a2ab71da752b8b072de
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
# Release History: opentelemetry-sdk
|
2
2
|
|
3
|
+
### v1.0.3 / 2022-05-02
|
4
|
+
|
5
|
+
* ADDED: Truncate the strings in an array attribute value if length_limit is configured
|
6
|
+
* FIXED: Update attribute length limit env var name to match spec
|
7
|
+
* FIXED: Warning about Struct initialization in Ruby 3.2+
|
8
|
+
* FIXED: Warn on unsupported otlp transport protocols
|
9
|
+
* FIXED: Only allow certain types of Numeric values as attribute values.
|
10
|
+
|
11
|
+
### v1.0.2 / 2021-12-01
|
12
|
+
|
13
|
+
* FIXED: Default span kind
|
14
|
+
* FIXED: Use monotonic clock where possible
|
15
|
+
|
16
|
+
### v1.0.1 / 2021-10-29
|
17
|
+
|
18
|
+
* FIXED: Add unexpected error handlign in BSP and OTLP exporter (#995)
|
19
|
+
|
3
20
|
### v1.0.0 / 2021-09-29
|
4
21
|
|
5
22
|
* (No significant changes)
|
@@ -169,12 +169,20 @@ module OpenTelemetry
|
|
169
169
|
processors.each { |p| tracer_provider.add_span_processor(p) }
|
170
170
|
end
|
171
171
|
|
172
|
-
def wrapped_exporters_from_env
|
172
|
+
def wrapped_exporters_from_env # rubocop:disable Metrics/CyclomaticComplexity, Metrics/AbcSize
|
173
173
|
exporters = ENV.fetch('OTEL_TRACES_EXPORTER', 'otlp')
|
174
174
|
exporters.split(',').map do |exporter|
|
175
175
|
case exporter.strip
|
176
176
|
when 'none' then nil
|
177
|
-
when 'otlp'
|
177
|
+
when 'otlp'
|
178
|
+
otlp_protocol = ENV['OTEL_EXPORTER_OTLP_TRACES_PROTOCOL'] || ENV['OTEL_EXPORTER_OTLP_PROTOCOL'] || 'http/protobuf'
|
179
|
+
|
180
|
+
if otlp_protocol != 'http/protobuf'
|
181
|
+
OpenTelemetry.logger.warn "The #{otlp_protocol} transport protocol is not supported by the OTLP exporter, spans will not be exported."
|
182
|
+
nil
|
183
|
+
else
|
184
|
+
fetch_exporter(exporter, 'OpenTelemetry::Exporter::OTLP::Exporter')
|
185
|
+
end
|
178
186
|
when 'jaeger' then fetch_exporter(exporter, 'OpenTelemetry::Exporter::Jaeger::CollectorExporter')
|
179
187
|
when 'zipkin' then fetch_exporter(exporter, 'OpenTelemetry::Exporter::Zipkin::Exporter')
|
180
188
|
when 'console' then Trace::Export::SimpleSpanProcessor.new(Trace::Export::ConsoleSpanExporter.new)
|
@@ -13,15 +13,19 @@ module OpenTelemetry
|
|
13
13
|
extend self
|
14
14
|
|
15
15
|
def boolean?(value)
|
16
|
-
value.
|
16
|
+
value.instance_of?(TrueClass) || value.instance_of?(FalseClass)
|
17
17
|
end
|
18
18
|
|
19
19
|
def valid_key?(key)
|
20
20
|
key.instance_of?(String)
|
21
21
|
end
|
22
22
|
|
23
|
+
def numeric?(value)
|
24
|
+
value.instance_of?(Integer) || value.instance_of?(Float)
|
25
|
+
end
|
26
|
+
|
23
27
|
def valid_simple_value?(value)
|
24
|
-
value.instance_of?(String) || value
|
28
|
+
value.instance_of?(String) || boolean?(value) || numeric?(value)
|
25
29
|
end
|
26
30
|
|
27
31
|
def valid_array_value?(value)
|
@@ -34,7 +38,7 @@ module OpenTelemetry
|
|
34
38
|
when TrueClass, FalseClass
|
35
39
|
value.all? { |v| boolean?(v) }
|
36
40
|
when Numeric
|
37
|
-
value.all? { |v|
|
41
|
+
value.all? { |v| numeric?(v) }
|
38
42
|
else
|
39
43
|
false
|
40
44
|
end
|
@@ -187,6 +187,10 @@ module OpenTelemetry
|
|
187
187
|
result_code = @export_mutex.synchronize { @exporter.export(batch, timeout: timeout) }
|
188
188
|
report_result(result_code, batch)
|
189
189
|
result_code
|
190
|
+
rescue StandardError => e
|
191
|
+
report_result(FAILURE, batch)
|
192
|
+
@metrics_reporter.add_to_counter('otel.bsp.error', labels: { 'reason' => e.class.to_s })
|
193
|
+
FAILURE
|
190
194
|
end
|
191
195
|
|
192
196
|
def report_result(result_code, batch)
|
@@ -131,7 +131,7 @@ module OpenTelemetry
|
|
131
131
|
#
|
132
132
|
# @return [self] returns itself
|
133
133
|
def add_event(name, attributes: nil, timestamp: nil)
|
134
|
-
event = Event.new(name, truncate_attribute_values(attributes),
|
134
|
+
event = Event.new(name, truncate_attribute_values(attributes), relative_timestamp(timestamp))
|
135
135
|
|
136
136
|
@mutex.synchronize do
|
137
137
|
if @ended
|
@@ -233,7 +233,7 @@ module OpenTelemetry
|
|
233
233
|
OpenTelemetry.logger.warn('Calling finish on an ended Span.')
|
234
234
|
return self
|
235
235
|
end
|
236
|
-
@end_timestamp =
|
236
|
+
@end_timestamp = relative_timestamp(end_timestamp)
|
237
237
|
@attributes = validated_attributes(@attributes).freeze
|
238
238
|
@events.freeze
|
239
239
|
@ended = true
|
@@ -276,7 +276,7 @@ module OpenTelemetry
|
|
276
276
|
end
|
277
277
|
|
278
278
|
# @api private
|
279
|
-
def initialize(context, parent_context, name, kind, parent_span_id, span_limits, span_processors, attributes, links, start_timestamp, resource, instrumentation_library) # rubocop:disable Metrics/AbcSize
|
279
|
+
def initialize(context, parent_context, parent_span, name, kind, parent_span_id, span_limits, span_processors, attributes, links, start_timestamp, resource, instrumentation_library) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
|
280
280
|
super(span_context: context)
|
281
281
|
@mutex = Mutex.new
|
282
282
|
@name = name
|
@@ -291,17 +291,45 @@ module OpenTelemetry
|
|
291
291
|
@total_recorded_events = 0
|
292
292
|
@total_recorded_links = links&.size || 0
|
293
293
|
@total_recorded_attributes = attributes&.size || 0
|
294
|
-
@start_timestamp = wall_clock(start_timestamp)
|
295
|
-
@end_timestamp = nil
|
296
294
|
@attributes = attributes.nil? ? nil : Hash[attributes] # We need a mutable copy of attributes.
|
297
295
|
trim_span_attributes(@attributes)
|
298
296
|
@events = nil
|
299
297
|
@links = trim_links(links, span_limits.link_count_limit, span_limits.link_attribute_count_limit)
|
298
|
+
|
299
|
+
# Times are hard. Whenever an explicit timestamp is provided
|
300
|
+
# (for Events or for the Span start_timestamp or end_timestamp),
|
301
|
+
# we use that as the recorded timestamp. An implicit Event timestamp
|
302
|
+
# and end_timestamp is computed as a monotonic clock offset from
|
303
|
+
# the realtime start_timestamp. The realtime start_timestamp is
|
304
|
+
# computed as a monotonic clock offset from the realtime
|
305
|
+
# start_timestamp of its parent span, if available, or it is
|
306
|
+
# fetched from the realtime system clock.
|
307
|
+
#
|
308
|
+
# We therefore have 3 start timestamps. The first two are used
|
309
|
+
# internally (and by child spans) to compute other timestamps.
|
310
|
+
# The last is the start timestamp actually recorded in the
|
311
|
+
# SpanData.
|
312
|
+
@monotonic_start_timestamp = monotonic_now
|
313
|
+
@realtime_start_timestamp = if parent_span.recording?
|
314
|
+
relative_realtime(parent_span.realtime_start_timestamp, parent_span.monotonic_start_timestamp)
|
315
|
+
else
|
316
|
+
realtime_now
|
317
|
+
end
|
318
|
+
@start_timestamp = if start_timestamp
|
319
|
+
time_in_nanoseconds(start_timestamp)
|
320
|
+
else
|
321
|
+
@realtime_start_timestamp
|
322
|
+
end
|
323
|
+
@end_timestamp = nil
|
300
324
|
@span_processors.each { |processor| processor.on_start(self, parent_context) }
|
301
325
|
end
|
302
326
|
|
303
327
|
# TODO: Java implementation overrides finalize to log if a span isn't finished.
|
304
328
|
|
329
|
+
protected
|
330
|
+
|
331
|
+
attr_reader :monotonic_start_timestamp, :realtime_start_timestamp
|
332
|
+
|
305
333
|
private
|
306
334
|
|
307
335
|
def validated_attributes(attrs)
|
@@ -323,7 +351,9 @@ module OpenTelemetry
|
|
323
351
|
return EMPTY_ATTRIBUTES if attrs.nil?
|
324
352
|
|
325
353
|
attribute_length_limit = @span_limits.attribute_length_limit
|
326
|
-
|
354
|
+
return attrs if attribute_length_limit.nil?
|
355
|
+
|
356
|
+
attrs.transform_values! { |value| OpenTelemetry::Common::Utilities.truncate_attribute_value(value, attribute_length_limit) }
|
327
357
|
attrs
|
328
358
|
end
|
329
359
|
|
@@ -376,9 +406,26 @@ module OpenTelemetry
|
|
376
406
|
events << event
|
377
407
|
end
|
378
408
|
|
379
|
-
def
|
380
|
-
|
381
|
-
|
409
|
+
def relative_timestamp(timestamp)
|
410
|
+
return time_in_nanoseconds(timestamp) unless timestamp.nil?
|
411
|
+
|
412
|
+
relative_realtime(realtime_start_timestamp, monotonic_start_timestamp)
|
413
|
+
end
|
414
|
+
|
415
|
+
def time_in_nanoseconds(timestamp)
|
416
|
+
(timestamp.to_r * 1_000_000_000).to_i
|
417
|
+
end
|
418
|
+
|
419
|
+
def relative_realtime(realtime_base, monotonic_base)
|
420
|
+
realtime_base + (monotonic_now - monotonic_base)
|
421
|
+
end
|
422
|
+
|
423
|
+
def realtime_now
|
424
|
+
Process.clock_gettime(Process::CLOCK_REALTIME, :nanosecond)
|
425
|
+
end
|
426
|
+
|
427
|
+
def monotonic_now
|
428
|
+
Process.clock_gettime(Process::CLOCK_MONOTONIC, :nanosecond)
|
382
429
|
end
|
383
430
|
end
|
384
431
|
# rubocop:enable Metrics/ClassLength
|
@@ -32,7 +32,8 @@ module OpenTelemetry
|
|
32
32
|
# @return [SpanLimits] with the desired values.
|
33
33
|
# @raise [ArgumentError] if any of the max numbers are not positive.
|
34
34
|
def initialize(attribute_count_limit: Integer(ENV.fetch('OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT', 128)), # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
35
|
-
attribute_length_limit: ENV
|
35
|
+
attribute_length_limit: ENV.fetch('OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT',
|
36
|
+
ENV['OTEL_RUBY_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT']),
|
36
37
|
event_count_limit: Integer(ENV.fetch('OTEL_SPAN_EVENT_COUNT_LIMIT', 128)),
|
37
38
|
link_count_limit: Integer(ENV.fetch('OTEL_SPAN_LINK_COUNT_LIMIT', 128)),
|
38
39
|
event_attribute_count_limit: Integer(ENV.fetch('OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT', 128)),
|
@@ -31,12 +31,14 @@ module OpenTelemetry
|
|
31
31
|
name ||= 'empty'
|
32
32
|
|
33
33
|
with_parent ||= Context.current
|
34
|
+
parent_span = OpenTelemetry::Trace.current_span(with_parent)
|
34
35
|
parent_span_context = OpenTelemetry::Trace.current_span(with_parent).context
|
35
36
|
if parent_span_context.valid?
|
36
37
|
parent_span_id = parent_span_context.span_id
|
37
38
|
trace_id = parent_span_context.trace_id
|
38
39
|
end
|
39
|
-
|
40
|
+
|
41
|
+
@tracer_provider.internal_create_span(name, kind, trace_id, parent_span_id, attributes, links, start_timestamp, with_parent, parent_span, @instrumentation_library)
|
40
42
|
end
|
41
43
|
end
|
42
44
|
end
|
@@ -126,8 +126,15 @@ module OpenTelemetry
|
|
126
126
|
end
|
127
127
|
|
128
128
|
# @api private
|
129
|
-
def internal_create_span(name, kind, trace_id, parent_span_id, attributes, links, start_timestamp, parent_context, instrumentation_library) # rubocop:disable Metrics/MethodLength
|
129
|
+
def internal_create_span(name, kind, trace_id, parent_span_id, attributes, links, start_timestamp, parent_context, parent_span, instrumentation_library) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
130
|
+
parent_span_context = parent_span.context
|
131
|
+
if parent_span_context.valid?
|
132
|
+
parent_span_id = parent_span_context.span_id
|
133
|
+
trace_id = parent_span_context.trace_id
|
134
|
+
end
|
135
|
+
name ||= 'empty'
|
130
136
|
trace_id ||= @id_generator.generate_trace_id
|
137
|
+
kind ||= :internal
|
131
138
|
result = @sampler.should_sample?(trace_id: trace_id, parent_context: parent_context, links: links, name: name, kind: kind, attributes: attributes)
|
132
139
|
span_id = @id_generator.generate_span_id
|
133
140
|
if result.recording? && !@stopped
|
@@ -137,6 +144,7 @@ module OpenTelemetry
|
|
137
144
|
Span.new(
|
138
145
|
context,
|
139
146
|
parent_context,
|
147
|
+
parent_span,
|
140
148
|
name,
|
141
149
|
kind,
|
142
150
|
parent_span_id,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opentelemetry-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
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: 2022-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opentelemetry-api
|
@@ -30,28 +30,28 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.19.
|
33
|
+
version: 0.19.3
|
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.19.
|
40
|
+
version: 0.19.3
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: opentelemetry-instrumentation-base
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.
|
47
|
+
version: 0.20.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.
|
54
|
+
version: 0.20.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: opentelemetry-semantic_conventions
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,6 +122,20 @@ dependencies:
|
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: 0.19.0
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: opentelemetry-test-helpers
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
140
|
name: pry
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -265,10 +279,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby
|
|
265
279
|
licenses:
|
266
280
|
- Apache-2.0
|
267
281
|
metadata:
|
268
|
-
changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk/v1.0.
|
282
|
+
changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk/v1.0.3/file.CHANGELOG.html
|
269
283
|
source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/sdk
|
270
284
|
bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby/issues
|
271
|
-
documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk/v1.0.
|
285
|
+
documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk/v1.0.3
|
272
286
|
post_install_message:
|
273
287
|
rdoc_options: []
|
274
288
|
require_paths:
|