opentelemetry-sdk 0.13.1 → 1.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +97 -42
- data/README.md +2 -2
- data/lib/opentelemetry/sdk.rb +2 -2
- data/lib/opentelemetry/sdk/configurator.rb +41 -45
- data/lib/opentelemetry/sdk/internal.rb +3 -3
- data/lib/opentelemetry/sdk/resources/constants.rb +48 -3
- data/lib/opentelemetry/sdk/trace/config/trace_config.rb +13 -7
- data/lib/opentelemetry/sdk/trace/event.rb +7 -36
- data/lib/opentelemetry/sdk/trace/export/batch_span_processor.rb +10 -5
- data/lib/opentelemetry/sdk/trace/export/console_span_exporter.rb +4 -0
- data/lib/opentelemetry/sdk/trace/export/in_memory_span_exporter.rb +23 -4
- data/lib/opentelemetry/sdk/trace/export/multi_span_exporter.rb +19 -2
- data/lib/opentelemetry/sdk/trace/export/noop_span_exporter.rb +10 -0
- data/lib/opentelemetry/sdk/trace/export/simple_span_processor.rb +4 -2
- data/lib/opentelemetry/sdk/trace/multi_span_processor.rb +2 -2
- data/lib/opentelemetry/sdk/trace/span.rb +54 -13
- data/lib/opentelemetry/sdk/trace/span_data.rb +25 -18
- data/lib/opentelemetry/sdk/trace/tracer.rb +1 -1
- data/lib/opentelemetry/sdk/trace/tracer_provider.rb +25 -7
- data/lib/opentelemetry/sdk/version.rb +1 -1
- metadata +39 -14
- data/lib/opentelemetry/sdk/baggage.rb +0 -16
- data/lib/opentelemetry/sdk/baggage/builder.rb +0 -40
- data/lib/opentelemetry/sdk/baggage/manager.rb +0 -97
@@ -10,24 +10,24 @@ module OpenTelemetry
|
|
10
10
|
# implementation.
|
11
11
|
module Trace
|
12
12
|
# SpanData is a Struct containing {Span} data for export.
|
13
|
-
SpanData = Struct.new(:name,
|
14
|
-
:kind,
|
15
|
-
:status,
|
16
|
-
:parent_span_id,
|
17
|
-
:total_recorded_attributes,
|
18
|
-
:total_recorded_events,
|
19
|
-
:total_recorded_links,
|
20
|
-
:start_timestamp,
|
21
|
-
:end_timestamp,
|
22
|
-
:attributes,
|
23
|
-
:links,
|
24
|
-
:events,
|
25
|
-
:resource,
|
26
|
-
:instrumentation_library,
|
27
|
-
:span_id,
|
28
|
-
:trace_id,
|
29
|
-
:trace_flags,
|
30
|
-
:tracestate) do
|
13
|
+
SpanData = Struct.new(:name, # String
|
14
|
+
:kind, # Symbol: :internal, :producer, :consumer, :client, :server
|
15
|
+
:status, # Status
|
16
|
+
:parent_span_id, # String (8 byte binary), may be OpenTelemetry::Trace::INVALID_SPAN_ID
|
17
|
+
:total_recorded_attributes, # Integer
|
18
|
+
:total_recorded_events, # Integer
|
19
|
+
:total_recorded_links, # Integer
|
20
|
+
:start_timestamp, # Integer nanoseconds since Epoch
|
21
|
+
:end_timestamp, # Integer nanoseconds since Epoch
|
22
|
+
:attributes, # optional Hash{String => String, Numeric, Boolean, Array<String, Numeric, Boolean>}
|
23
|
+
:links, # optional Array[OpenTelemetry::Trace::Link]
|
24
|
+
:events, # optional Array[Event]
|
25
|
+
:resource, # OpenTelemetry::SDK::Resources::Resource
|
26
|
+
:instrumentation_library, # OpenTelemetry::SDK::InstrumentationLibrary
|
27
|
+
:span_id, # String (8 byte binary)
|
28
|
+
:trace_id, # String (16-byte binary)
|
29
|
+
:trace_flags, # Integer (8-bit byte of bit flags)
|
30
|
+
:tracestate) do # OpenTelemetry::Trace::Tracestate
|
31
31
|
# Returns the lowercase [hex encoded](https://tools.ietf.org/html/rfc4648#section-8) span ID.
|
32
32
|
#
|
33
33
|
# @return [String] A 16-hex-character lowercase string.
|
@@ -41,6 +41,13 @@ module OpenTelemetry
|
|
41
41
|
def hex_trace_id
|
42
42
|
trace_id.unpack1('H*')
|
43
43
|
end
|
44
|
+
|
45
|
+
# Returns the lowercase [hex encoded](https://tools.ietf.org/html/rfc4648#section-8) parent span ID.
|
46
|
+
#
|
47
|
+
# @return [String] A 16-hex-character lowercase string.
|
48
|
+
def hex_parent_span_id
|
49
|
+
parent_span_id.unpack1('H*')
|
50
|
+
end
|
44
51
|
end
|
45
52
|
end
|
46
53
|
end
|
@@ -42,7 +42,7 @@ module OpenTelemetry
|
|
42
42
|
@mutex.synchronize { @registry[Key.new(name, version)] ||= Tracer.new(name, version, self) }
|
43
43
|
end
|
44
44
|
|
45
|
-
# Attempts to stop all the activity for this {
|
45
|
+
# Attempts to stop all the activity for this {TracerProvider}. Calls
|
46
46
|
# SpanProcessor#shutdown for all registered SpanProcessors.
|
47
47
|
#
|
48
48
|
# This operation may block until all the Spans are processed. Must be
|
@@ -63,12 +63,26 @@ module OpenTelemetry
|
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
|
-
#
|
66
|
+
# Immediately export all spans that have not yet been exported for all the
|
67
|
+
# registered SpanProcessors.
|
68
|
+
#
|
69
|
+
# This method should only be called in cases where it is absolutely
|
70
|
+
# necessary, such as when using some FaaS providers that may suspend
|
71
|
+
# the process after an invocation, but before the `Processor` exports
|
72
|
+
# the completed spans.
|
67
73
|
#
|
68
|
-
#
|
69
|
-
#
|
70
|
-
#
|
71
|
-
|
74
|
+
# @param [optional Numeric] timeout An optional timeout in seconds.
|
75
|
+
# @return [Integer] Export::SUCCESS if no error occurred, Export::FAILURE if
|
76
|
+
# a non-specific failure occurred, Export::TIMEOUT if a timeout occurred.
|
77
|
+
def force_flush(timeout: nil)
|
78
|
+
@mutex.synchronize do
|
79
|
+
return Export::SUCCESS if @stopped
|
80
|
+
|
81
|
+
@active_span_processor.force_flush(timeout: timeout)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
# Adds a new SpanProcessor to this {Tracer}.
|
72
86
|
#
|
73
87
|
# @param span_processor the new SpanProcessor to be added.
|
74
88
|
def add_span_processor(span_processor)
|
@@ -78,7 +92,11 @@ module OpenTelemetry
|
|
78
92
|
return
|
79
93
|
end
|
80
94
|
@registered_span_processors << span_processor
|
81
|
-
@active_span_processor =
|
95
|
+
@active_span_processor = if @registered_span_processors.size == 1
|
96
|
+
span_processor
|
97
|
+
else
|
98
|
+
MultiSpanProcessor.new(@registered_span_processors.dup)
|
99
|
+
end
|
82
100
|
end
|
83
101
|
end
|
84
102
|
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: 1.0.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- OpenTelemetry Authors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opentelemetry-api
|
@@ -16,28 +16,42 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 1.0.0.rc1
|
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: 1.0.0.rc1
|
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.18.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.18.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: opentelemetry-instrumentation-base
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.18.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.18.0
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: bundler
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,6 +94,20 @@ dependencies:
|
|
80
94
|
- - "~>"
|
81
95
|
- !ruby/object:Gem::Version
|
82
96
|
version: '5.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: opentelemetry-exporter-jaeger
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.18.0
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.18.0
|
83
111
|
- !ruby/object:Gem::Dependency
|
84
112
|
name: rake
|
85
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -163,9 +191,6 @@ files:
|
|
163
191
|
- README.md
|
164
192
|
- lib/opentelemetry-sdk.rb
|
165
193
|
- lib/opentelemetry/sdk.rb
|
166
|
-
- lib/opentelemetry/sdk/baggage.rb
|
167
|
-
- lib/opentelemetry/sdk/baggage/builder.rb
|
168
|
-
- lib/opentelemetry/sdk/baggage/manager.rb
|
169
194
|
- lib/opentelemetry/sdk/configurator.rb
|
170
195
|
- lib/opentelemetry/sdk/instrumentation_library.rb
|
171
196
|
- lib/opentelemetry/sdk/internal.rb
|
@@ -201,10 +226,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby
|
|
201
226
|
licenses:
|
202
227
|
- Apache-2.0
|
203
228
|
metadata:
|
204
|
-
changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk/
|
229
|
+
changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk/v1.0.0.rc1/file.CHANGELOG.html
|
205
230
|
source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/sdk
|
206
231
|
bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby/issues
|
207
|
-
documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk/
|
232
|
+
documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk/v1.0.0.rc1
|
208
233
|
post_install_message:
|
209
234
|
rdoc_options: []
|
210
235
|
require_paths:
|
@@ -216,11 +241,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
216
241
|
version: 2.5.0
|
217
242
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
218
243
|
requirements:
|
219
|
-
- - "
|
244
|
+
- - ">"
|
220
245
|
- !ruby/object:Gem::Version
|
221
|
-
version:
|
246
|
+
version: 1.3.1
|
222
247
|
requirements: []
|
223
|
-
rubygems_version: 3.1.
|
248
|
+
rubygems_version: 3.1.6
|
224
249
|
signing_key:
|
225
250
|
specification_version: 4
|
226
251
|
summary: A stats collection and distributed tracing framework
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright The OpenTelemetry Authors
|
4
|
-
#
|
5
|
-
# SPDX-License-Identifier: Apache-2.0
|
6
|
-
|
7
|
-
require 'opentelemetry/sdk/baggage/builder'
|
8
|
-
require 'opentelemetry/sdk/baggage/manager'
|
9
|
-
|
10
|
-
module OpenTelemetry
|
11
|
-
module SDK
|
12
|
-
# Contains operational implementations of the Baggage::Manager
|
13
|
-
module Baggage
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,40 +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 Baggage
|
10
|
-
# SDK implementation of Baggage::Builder
|
11
|
-
class Builder
|
12
|
-
attr_reader :entries
|
13
|
-
|
14
|
-
def initialize(entries)
|
15
|
-
@entries = entries
|
16
|
-
end
|
17
|
-
|
18
|
-
# Set key-value in the to-be-created baggage
|
19
|
-
#
|
20
|
-
# @param [String] key The key to store this value under
|
21
|
-
# @param [String] value String value to be stored under key
|
22
|
-
def set_value(key, value)
|
23
|
-
@entries[key] = value.to_s
|
24
|
-
end
|
25
|
-
|
26
|
-
# Removes key from the to-be-created baggage
|
27
|
-
#
|
28
|
-
# @param [String] key The key to remove
|
29
|
-
def remove_value(key)
|
30
|
-
@entries.delete(key)
|
31
|
-
end
|
32
|
-
|
33
|
-
# Clears all baggage from the to-be-created baggage
|
34
|
-
def clear
|
35
|
-
@entries.clear
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,97 +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 Baggage
|
10
|
-
# Manages baggage
|
11
|
-
class Manager
|
12
|
-
BAGGAGE_KEY = OpenTelemetry::Baggage::Propagation::ContextKeys.baggage_key
|
13
|
-
EMPTY_BAGGAGE = {}.freeze
|
14
|
-
private_constant(:BAGGAGE_KEY, :EMPTY_BAGGAGE)
|
15
|
-
|
16
|
-
# Used to chain modifications to baggage. The result is a
|
17
|
-
# context with an updated baggage. If only a single
|
18
|
-
# modification is being made to baggage, use the other
|
19
|
-
# methods on +Manager+, if multiple modifications are being made, use
|
20
|
-
# this one.
|
21
|
-
#
|
22
|
-
# @param [optional Context] context The context to update with with new
|
23
|
-
# modified baggage. Defaults to +Context.current+
|
24
|
-
# @return [Context]
|
25
|
-
def build_context(context: Context.current)
|
26
|
-
builder = Builder.new(baggage_for(context).dup)
|
27
|
-
yield builder
|
28
|
-
context.set_value(BAGGAGE_KEY, builder.entries)
|
29
|
-
end
|
30
|
-
|
31
|
-
# Returns a new context with empty baggage
|
32
|
-
#
|
33
|
-
# @param [optional Context] context Context to clear baggage from. Defaults
|
34
|
-
# to +Context.current+
|
35
|
-
# @return [Context]
|
36
|
-
def clear(context: Context.current)
|
37
|
-
context.set_value(BAGGAGE_KEY, EMPTY_BAGGAGE)
|
38
|
-
end
|
39
|
-
|
40
|
-
# Returns the corresponding baggage value (or nil) for key
|
41
|
-
#
|
42
|
-
# @param [String] key The lookup key
|
43
|
-
# @param [optional Context] context The context from which to retrieve
|
44
|
-
# the key.
|
45
|
-
# Defaults to +Context.current+
|
46
|
-
# @return [String]
|
47
|
-
def value(key, context: Context.current)
|
48
|
-
baggage_for(context)[key]
|
49
|
-
end
|
50
|
-
|
51
|
-
# Returns the baggage
|
52
|
-
#
|
53
|
-
# @param [optional Context] context The context from which to retrieve
|
54
|
-
# the baggage.
|
55
|
-
# Defaults to +Context.current+
|
56
|
-
# @return [Hash]
|
57
|
-
def values(context: Context.current)
|
58
|
-
baggage_for(context).dup.freeze
|
59
|
-
end
|
60
|
-
|
61
|
-
# Returns a new context with new key-value pair
|
62
|
-
#
|
63
|
-
# @param [String] key The key to store this value under
|
64
|
-
# @param [String] value String value to be stored under key
|
65
|
-
# @param [optional Context] context The context to update with new
|
66
|
-
# value. Defaults to +Context.current+
|
67
|
-
# @return [Context]
|
68
|
-
def set_value(key, value, context: Context.current)
|
69
|
-
new_baggage = baggage_for(context).dup
|
70
|
-
new_baggage[key] = value
|
71
|
-
context.set_value(BAGGAGE_KEY, new_baggage)
|
72
|
-
end
|
73
|
-
|
74
|
-
# Returns a new context with value at key removed
|
75
|
-
#
|
76
|
-
# @param [String] key The key to remove
|
77
|
-
# @param [optional Context] context The context to remove baggage
|
78
|
-
# from. Defaults to +Context.current+
|
79
|
-
# @return [Context]
|
80
|
-
def remove_value(key, context: Context.current)
|
81
|
-
baggage = baggage_for(context)
|
82
|
-
return context unless baggage.key?(key)
|
83
|
-
|
84
|
-
new_baggage = baggage.dup
|
85
|
-
new_baggage.delete(key)
|
86
|
-
context.set_value(BAGGAGE_KEY, new_baggage)
|
87
|
-
end
|
88
|
-
|
89
|
-
private
|
90
|
-
|
91
|
-
def baggage_for(context)
|
92
|
-
context.value(BAGGAGE_KEY) || EMPTY_BAGGAGE
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|