opentelemetry-sdk 0.17.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,18 +0,0 @@
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
- # The Config module contains the configuration logic for the
11
- # OpenTelemetry SDK.
12
- module Config
13
- end
14
- end
15
- end
16
- end
17
-
18
- require 'opentelemetry/sdk/trace/config/trace_config'
@@ -1,76 +0,0 @@
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
- # Implementation of the SpanExporter duck type that simply forwards all
12
- # received spans to a collection of SpanExporters.
13
- #
14
- # Can be used to export to multiple backends using the same
15
- # SpanProcessor like a {SimpleSpanProcessor} or a
16
- # {BatchSpanProcessor}.
17
- class MultiSpanExporter
18
- def initialize(span_exporters)
19
- @span_exporters = span_exporters.clone.freeze
20
- end
21
-
22
- # Called to export sampled {Span}s.
23
- #
24
- # @param [Enumerable<Span>] spans the list of sampled {Span}s to be
25
- # exported.
26
- # @param [optional Numeric] timeout An optional timeout in seconds.
27
- # @return [Integer] the result of the export.
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))
32
- rescue => e # rubocop:disable Style/RescueStandardError
33
- OpenTelemetry.logger.warn("exception raised by export - #{e}")
34
- FAILURE
35
- end
36
- results.uniq.max || SUCCESS
37
- end
38
-
39
- # Called when {TracerProvider#force_flush} is called, if this exporter is
40
- # registered to a {TracerProvider} object.
41
- #
42
- # @param [optional Numeric] timeout An optional timeout in seconds.
43
- # @return [Integer] SUCCESS if no error occurred, FAILURE if a
44
- # non-specific failure occurred, TIMEOUT if a timeout occurred.
45
- def force_flush(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?
50
-
51
- processor.force_flush(timeout: remaining_timeout)
52
- end
53
- results.uniq.max || SUCCESS
54
- end
55
-
56
- # Called when {TracerProvider#shutdown} is called, if this exporter is
57
- # registered to a {TracerProvider} object.
58
- #
59
- # @param [optional Numeric] timeout An optional timeout in seconds.
60
- # @return [Integer] SUCCESS if no error occurred, FAILURE if a
61
- # non-specific failure occurred, TIMEOUT if a timeout occurred.
62
- def shutdown(timeout: nil)
63
- start_time = Time.now
64
- results = @span_exporters.map do |processor|
65
- remaining_timeout = OpenTelemetry::Common::Utilities.maybe_timeout(timeout, start_time)
66
- return TIMEOUT if remaining_timeout&.zero?
67
-
68
- processor.shutdown(timeout: remaining_timeout)
69
- end
70
- results.uniq.max || SUCCESS
71
- end
72
- end
73
- end
74
- end
75
- end
76
- end
@@ -1,86 +0,0 @@
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
- # Implementation of the SpanProcessor duck type that simply forwards all
11
- # received events to a list of SpanProcessors.
12
- class MultiSpanProcessor
13
- # Creates a new {MultiSpanProcessor}.
14
- #
15
- # @param [Enumerable<SpanProcessor>] span_processors a collection of
16
- # SpanProcessors.
17
- # @return [MultiSpanProcessor]
18
- def initialize(span_processors)
19
- @span_processors = span_processors.to_a.freeze
20
- end
21
-
22
- # Called when a {Span} is started, if the {Span#recording?}
23
- # returns true.
24
- #
25
- # This method is called synchronously on the execution thread, should
26
- # not throw or block the execution thread.
27
- #
28
- # @param [Span] span the {Span} that just started.
29
- # @param [Context] parent_context the parent {Context} of the newly
30
- # started span.
31
- def on_start(span, parent_context)
32
- @span_processors.each { |processor| processor.on_start(span, parent_context) }
33
- end
34
-
35
- # Called when a {Span} is ended, if the {Span#recording?}
36
- # returns true.
37
- #
38
- # This method is called synchronously on the execution thread, should
39
- # not throw or block the execution thread.
40
- #
41
- # @param [Span] span the {Span} that just ended.
42
- def on_finish(span)
43
- @span_processors.each { |processor| processor.on_finish(span) }
44
- end
45
-
46
- # Export all ended spans to the configured `Exporter` that have not yet
47
- # been exported.
48
- #
49
- # This method should only be called in cases where it is absolutely
50
- # necessary, such as when using some FaaS providers that may suspend
51
- # the process after an invocation, but before the `Processor` exports
52
- # the completed spans.
53
- #
54
- # @param [optional Numeric] timeout An optional timeout in seconds.
55
- # @return [Integer] Export::SUCCESS if no error occurred, Export::FAILURE if
56
- # a non-specific failure occurred, Export::TIMEOUT if a timeout occurred.
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
66
- end
67
-
68
- # Called when {TracerProvider#shutdown} is called.
69
- #
70
- # @param [optional Numeric] timeout An optional timeout in seconds.
71
- # @return [Integer] Export::SUCCESS if no error occurred, Export::FAILURE if
72
- # a non-specific failure occurred, Export::TIMEOUT if a timeout occurred.
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
82
- end
83
- end
84
- end
85
- end
86
- end