opentelemetry-api 1.0.0.rc1 → 1.0.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -1
- data/lib/opentelemetry.rb +1 -8
- data/lib/opentelemetry/baggage.rb +93 -3
- data/lib/opentelemetry/baggage/propagation/text_map_propagator.rb +3 -2
- data/lib/opentelemetry/context.rb +48 -33
- data/lib/opentelemetry/trace.rb +10 -0
- data/lib/opentelemetry/trace/propagation/trace_context/text_map_propagator.rb +2 -2
- data/lib/opentelemetry/trace/status.rb +34 -5
- data/lib/opentelemetry/trace/tracer.rb +6 -7
- data/lib/opentelemetry/version.rb +1 -1
- metadata +4 -8
- data/lib/opentelemetry/baggage/manager.rb +0 -104
- data/lib/opentelemetry/baggage/noop_builder.rb +0 -18
- data/lib/opentelemetry/baggage/noop_manager.rb +0 -45
- data/lib/opentelemetry/trace/util/http_to_status.rb +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 87cc02bff4251a383a6bd5ea88b50f0c47b6aeb206d2585a6ddccbc9811aa503
|
4
|
+
data.tar.gz: 1ce534ee66ea666a853e2625563c515f7a7439c791401997c3a35c7515849fcd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ea3d7eca27eda27dd1954cd9056ba3567a3d68ccafda1a55f9683acc381ef18e37ef319d12124ef11fe4b75af528c7d4157b8b7ed15d7dbde81487e36565c70
|
7
|
+
data.tar.gz: 878d7960e8b69e8d02a5e9354b8737250f7abacd9656b09b3ccd72d493abcdbd20aae4a76e5ff63d9dd8050a6714b410d948ad81cb489c5af8a44856316f4e35
|
data/CHANGELOG.md
CHANGED
@@ -1,10 +1,27 @@
|
|
1
1
|
# Release History: opentelemetry-api
|
2
2
|
|
3
|
+
### v1.0.0.rc2 / 2021-06-23
|
4
|
+
|
5
|
+
* BREAKING CHANGE: Remove optional parent_context from in_span [729](https://github.com/open-telemetry/opentelemetry-ruby/pull/729)
|
6
|
+
* BREAKING CHANGE: Refactor Baggage to remove Noop* [800](https://github.com/open-telemetry/opentelemetry-ruby/pull/800)
|
7
|
+
- The noop baggage manger has been removed.
|
8
|
+
- The baggage management methods are now available through OpenTelemetry::Baggage#method, previously OpenTelemetry.baggage#method
|
9
|
+
* BREAKING CHANGE: Total order constraint on span.status= [805](https://github.com/open-telemetry/opentelemetry-ruby/pull/805)
|
10
|
+
- The OpenTelemetry::Trace::Util::HttpToStatus module has been removed as it was incorrectly setting the span status to OK for codes codes in the range 100..399
|
11
|
+
- The HttpToStatus module can be replaced inline as follows `span.status = OpenTelemetry::Trace::Status.error unless (100..399).include?(response_code.to_i)`
|
12
|
+
- The `Status.new(code, description:)` initializer has been hidden in favour of simpler constructors for each status code: `Status.ok`, `Status.error` and `Status.unset`. Each constructor takes an optional description.
|
13
|
+
|
14
|
+
* ADDED: Add Tracer.non_recording_span to API [799](https://github.com/open-telemetry/opentelemetry-ruby/pull/799)
|
15
|
+
* FIXED: Reduce span allocation in API [795](https://github.com/open-telemetry/opentelemetry-ruby/pull/795)
|
16
|
+
* FIXED: Return early if carrier is nil [835](https://github.com/open-telemetry/opentelemetry-ruby/pull/835)
|
17
|
+
* FIXED: Update context to match spec [807](https://github.com/open-telemetry/opentelemetry-ruby/pull/807)
|
18
|
+
- The `Context.current` setter has been removed and the previously private attach/detach methods are now available as class methods on the context module.
|
19
|
+
|
3
20
|
### v1.0.0.rc1 / 2021-05-21
|
4
21
|
|
5
22
|
* BREAKING CHANGE: Remove optional parent_context from in_span
|
6
23
|
|
7
|
-
* FIXED: Remove optional parent_context from in_span
|
24
|
+
* FIXED: Remove optional parent_context from in_span
|
8
25
|
|
9
26
|
### v0.17.0 / 2021-04-22
|
10
27
|
|
data/lib/opentelemetry.rb
CHANGED
@@ -24,7 +24,7 @@ module OpenTelemetry
|
|
24
24
|
@mutex = Mutex.new
|
25
25
|
@tracer_provider = Internal::ProxyTracerProvider.new
|
26
26
|
|
27
|
-
attr_writer :propagation, :
|
27
|
+
attr_writer :propagation, :logger, :error_handler
|
28
28
|
|
29
29
|
# @return [Object, Logger] configured Logger or a default STDOUT Logger.
|
30
30
|
def logger
|
@@ -65,13 +65,6 @@ module OpenTelemetry
|
|
65
65
|
@mutex.synchronize { @tracer_provider }
|
66
66
|
end
|
67
67
|
|
68
|
-
# @return [Object, Baggage::NoopManager] registered
|
69
|
-
# baggage manager or a default no-op implementation of the
|
70
|
-
# manager.
|
71
|
-
def baggage
|
72
|
-
@baggage ||= Baggage::NoopManager.new
|
73
|
-
end
|
74
|
-
|
75
68
|
# @return [Context::Propagation::Propagator] a propagator instance
|
76
69
|
def propagation
|
77
70
|
@propagation ||= Context::Propagation::NoopTextMapPropagator.new
|
@@ -7,13 +7,103 @@
|
|
7
7
|
require 'opentelemetry/baggage/propagation'
|
8
8
|
require 'opentelemetry/baggage/builder'
|
9
9
|
require 'opentelemetry/baggage/entry'
|
10
|
-
require 'opentelemetry/baggage/manager'
|
11
|
-
require 'opentelemetry/baggage/noop_builder'
|
12
|
-
require 'opentelemetry/baggage/noop_manager'
|
13
10
|
|
14
11
|
module OpenTelemetry
|
15
12
|
# The Baggage module provides functionality to record and propagate
|
16
13
|
# baggage in a distributed trace
|
17
14
|
module Baggage
|
15
|
+
extend self
|
16
|
+
|
17
|
+
BAGGAGE_KEY = OpenTelemetry::Baggage::Propagation::ContextKeys.baggage_key
|
18
|
+
EMPTY_BAGGAGE = {}.freeze
|
19
|
+
private_constant(:BAGGAGE_KEY, :EMPTY_BAGGAGE)
|
20
|
+
|
21
|
+
# Used to chain modifications to baggage. The result is a
|
22
|
+
# context with an updated baggage. If only a single
|
23
|
+
# modification is being made to baggage, use the other
|
24
|
+
# methods on +Baggage+, if multiple modifications are being made, use
|
25
|
+
# this one.
|
26
|
+
#
|
27
|
+
# @param [optional Context] context The context to update with with new
|
28
|
+
# modified baggage. Defaults to +Context.current+
|
29
|
+
# @return [Context]
|
30
|
+
def build(context: Context.current)
|
31
|
+
builder = Builder.new(baggage_for(context).dup)
|
32
|
+
yield builder
|
33
|
+
context.set_value(BAGGAGE_KEY, builder.entries)
|
34
|
+
end
|
35
|
+
|
36
|
+
# Returns a new context with empty baggage
|
37
|
+
#
|
38
|
+
# @param [optional Context] context Context to clear baggage from. Defaults
|
39
|
+
# to +Context.current+
|
40
|
+
# @return [Context]
|
41
|
+
def clear(context: Context.current)
|
42
|
+
context.set_value(BAGGAGE_KEY, EMPTY_BAGGAGE)
|
43
|
+
end
|
44
|
+
|
45
|
+
# Returns the corresponding baggage.entry (or nil) for key
|
46
|
+
#
|
47
|
+
# @param [String] key The lookup key
|
48
|
+
# @param [optional Context] context The context from which to retrieve
|
49
|
+
# the key.
|
50
|
+
# Defaults to +Context.current+
|
51
|
+
# @return [String]
|
52
|
+
def value(key, context: Context.current)
|
53
|
+
baggage_for(context)[key]&.value
|
54
|
+
end
|
55
|
+
|
56
|
+
# Returns the baggage
|
57
|
+
#
|
58
|
+
# @param [optional Context] context The context from which to retrieve
|
59
|
+
# the baggage.
|
60
|
+
# Defaults to +Context.current+
|
61
|
+
# @return [Hash]
|
62
|
+
def values(context: Context.current)
|
63
|
+
baggage_for(context).transform_values(&:value)
|
64
|
+
end
|
65
|
+
|
66
|
+
# @api private
|
67
|
+
def raw_entries(context: Context.current)
|
68
|
+
baggage_for(context).dup.freeze
|
69
|
+
end
|
70
|
+
|
71
|
+
# Returns a new context with new key-value pair
|
72
|
+
#
|
73
|
+
# @param [String] key The key to store this value under
|
74
|
+
# @param [String] value String value to be stored under key
|
75
|
+
# @param [optional String] metadata This is here to store properties
|
76
|
+
# received from other W3C Baggage impelmentations but is not exposed in
|
77
|
+
# OpenTelemetry. This is condsidered private API and not for use by
|
78
|
+
# end-users.
|
79
|
+
# @param [optional Context] context The context to update with new
|
80
|
+
# value. Defaults to +Context.current+
|
81
|
+
# @return [Context]
|
82
|
+
def set_value(key, value, metadata: nil, context: Context.current)
|
83
|
+
new_baggage = baggage_for(context).dup
|
84
|
+
new_baggage[key] = Entry.new(value, metadata)
|
85
|
+
context.set_value(BAGGAGE_KEY, new_baggage)
|
86
|
+
end
|
87
|
+
|
88
|
+
# Returns a new context with value at key removed
|
89
|
+
#
|
90
|
+
# @param [String] key The key to remove
|
91
|
+
# @param [optional Context] context The context to remove baggage
|
92
|
+
# from. Defaults to +Context.current+
|
93
|
+
# @return [Context]
|
94
|
+
def remove_value(key, context: Context.current)
|
95
|
+
baggage = baggage_for(context)
|
96
|
+
return context unless baggage.key?(key)
|
97
|
+
|
98
|
+
new_baggage = baggage.dup
|
99
|
+
new_baggage.delete(key)
|
100
|
+
context.set_value(BAGGAGE_KEY, new_baggage)
|
101
|
+
end
|
102
|
+
|
103
|
+
private
|
104
|
+
|
105
|
+
def baggage_for(context)
|
106
|
+
context.value(BAGGAGE_KEY) || EMPTY_BAGGAGE
|
107
|
+
end
|
18
108
|
end
|
19
109
|
end
|
@@ -29,7 +29,7 @@ module OpenTelemetry
|
|
29
29
|
# will be used to write context into the carrier, otherwise the default
|
30
30
|
# text map setter will be used.
|
31
31
|
def inject(carrier, context: Context.current, setter: Context::Propagation.text_map_setter)
|
32
|
-
baggage = OpenTelemetry.
|
32
|
+
baggage = OpenTelemetry::Baggage.raw_entries(context: context)
|
33
33
|
|
34
34
|
return if baggage.nil? || baggage.empty?
|
35
35
|
|
@@ -52,10 +52,11 @@ module OpenTelemetry
|
|
52
52
|
# if extraction fails
|
53
53
|
def extract(carrier, context: Context.current, getter: Context::Propagation.text_map_getter)
|
54
54
|
header = getter.get(carrier, BAGGAGE_KEY)
|
55
|
+
return context unless header
|
55
56
|
|
56
57
|
entries = header.gsub(/\s/, '').split(',')
|
57
58
|
|
58
|
-
OpenTelemetry.
|
59
|
+
OpenTelemetry::Baggage.build(context: context) do |builder|
|
59
60
|
entries.each do |entry|
|
60
61
|
# Note metadata is currently unused in OpenTelemetry, but is part
|
61
62
|
# the W3C spec where it's referred to as properties. We preserve
|
@@ -10,8 +10,11 @@ require 'opentelemetry/context/propagation'
|
|
10
10
|
module OpenTelemetry
|
11
11
|
# Manages context on a per-fiber basis
|
12
12
|
class Context
|
13
|
-
KEY = :__opentelemetry_context__
|
14
13
|
EMPTY_ENTRIES = {}.freeze
|
14
|
+
STACK_KEY = :__opentelemetry_context_storage__
|
15
|
+
private_constant :EMPTY_ENTRIES, :STACK_KEY
|
16
|
+
|
17
|
+
DetachError = Class.new(OpenTelemetry::Error)
|
15
18
|
|
16
19
|
class << self
|
17
20
|
# Returns a key used to index a value in a Context
|
@@ -26,14 +29,36 @@ module OpenTelemetry
|
|
26
29
|
#
|
27
30
|
# @return [Context]
|
28
31
|
def current
|
29
|
-
|
32
|
+
stack.last || ROOT
|
30
33
|
end
|
31
34
|
|
32
|
-
#
|
35
|
+
# Associates a Context with the caller's current Fiber. Every call to
|
36
|
+
# this operation should be paired with a corresponding call to detach.
|
33
37
|
#
|
34
|
-
#
|
35
|
-
|
36
|
-
|
38
|
+
# Returns a token to be used with the matching call to detach
|
39
|
+
#
|
40
|
+
# @param [Context] context The new context
|
41
|
+
# @return [Object] A token to be used when detaching
|
42
|
+
def attach(context)
|
43
|
+
s = stack
|
44
|
+
s.push(context)
|
45
|
+
s.size
|
46
|
+
end
|
47
|
+
|
48
|
+
# Restores the previous Context associated with the current Fiber.
|
49
|
+
# The supplied token is used to check if the call to detach is balanced
|
50
|
+
# with a corresponding attach call. A warning is logged if the
|
51
|
+
# calls are unbalanced.
|
52
|
+
#
|
53
|
+
# @param [Object] token The token provided by the matching call to attach
|
54
|
+
# @return [Boolean] True if the calls matched, false otherwise
|
55
|
+
def detach(token)
|
56
|
+
s = stack
|
57
|
+
calls_matched = (token == s.size)
|
58
|
+
OpenTelemetry.handle_error(exception: DetachError.new('calls to detach should match corresponding calls to attach.')) unless calls_matched
|
59
|
+
|
60
|
+
s.pop
|
61
|
+
calls_matched
|
37
62
|
end
|
38
63
|
|
39
64
|
# Executes a block with ctx as the current context. It restores
|
@@ -42,10 +67,10 @@ module OpenTelemetry
|
|
42
67
|
# @param [Context] ctx The context to be made active
|
43
68
|
# @yield [context] Yields context to the block
|
44
69
|
def with_current(ctx)
|
45
|
-
|
70
|
+
token = attach(ctx)
|
46
71
|
yield ctx
|
47
72
|
ensure
|
48
|
-
|
73
|
+
detach(token)
|
49
74
|
end
|
50
75
|
|
51
76
|
# Execute a block in a new context with key set to value. Restores the
|
@@ -58,10 +83,10 @@ module OpenTelemetry
|
|
58
83
|
# the block
|
59
84
|
def with_value(key, value)
|
60
85
|
ctx = current.set_value(key, value)
|
61
|
-
|
86
|
+
token = attach(ctx)
|
62
87
|
yield ctx, value
|
63
88
|
ensure
|
64
|
-
|
89
|
+
detach(token)
|
65
90
|
end
|
66
91
|
|
67
92
|
# Execute a block in a new context where its values are merged with the
|
@@ -75,10 +100,10 @@ module OpenTelemetry
|
|
75
100
|
# to the block
|
76
101
|
def with_values(values)
|
77
102
|
ctx = current.set_values(values)
|
78
|
-
|
103
|
+
token = attach(ctx)
|
79
104
|
yield ctx, values
|
80
105
|
ensure
|
81
|
-
|
106
|
+
detach(token)
|
82
107
|
end
|
83
108
|
|
84
109
|
# Returns the value associated with key in the current context
|
@@ -89,16 +114,21 @@ module OpenTelemetry
|
|
89
114
|
end
|
90
115
|
|
91
116
|
def clear
|
92
|
-
|
117
|
+
stack.clear
|
93
118
|
end
|
94
119
|
|
95
120
|
def empty
|
96
|
-
new(
|
121
|
+
new(EMPTY_ENTRIES)
|
122
|
+
end
|
123
|
+
|
124
|
+
private
|
125
|
+
|
126
|
+
def stack
|
127
|
+
Thread.current[STACK_KEY] ||= []
|
97
128
|
end
|
98
129
|
end
|
99
130
|
|
100
|
-
def initialize(
|
101
|
-
@parent = parent
|
131
|
+
def initialize(entries)
|
102
132
|
@entries = entries.freeze
|
103
133
|
end
|
104
134
|
|
@@ -120,7 +150,7 @@ module OpenTelemetry
|
|
120
150
|
def set_value(key, value)
|
121
151
|
new_entries = @entries.dup
|
122
152
|
new_entries[key] = value
|
123
|
-
Context.new(
|
153
|
+
Context.new(new_entries)
|
124
154
|
end
|
125
155
|
|
126
156
|
# Returns a new Context with the current context's entries merged with the
|
@@ -131,22 +161,7 @@ module OpenTelemetry
|
|
131
161
|
# @param [Object] value Object to be stored under key
|
132
162
|
# @return [Context]
|
133
163
|
def set_values(values) # rubocop:disable Naming/AccessorMethodName:
|
134
|
-
Context.new(
|
135
|
-
end
|
136
|
-
|
137
|
-
# @api private
|
138
|
-
def attach
|
139
|
-
prev = self.class.current
|
140
|
-
self.class.current = self
|
141
|
-
prev
|
142
|
-
end
|
143
|
-
|
144
|
-
# @api private
|
145
|
-
def detach(ctx_to_attach = nil)
|
146
|
-
OpenTelemetry.logger.warn 'Calls to detach should match corresponding calls to attach' if self.class.current != self
|
147
|
-
|
148
|
-
ctx_to_attach ||= @parent || ROOT
|
149
|
-
ctx_to_attach.attach
|
164
|
+
Context.new(@entries.merge(values))
|
150
165
|
end
|
151
166
|
|
152
167
|
ROOT = empty.freeze
|
data/lib/opentelemetry/trace.rb
CHANGED
@@ -81,6 +81,16 @@ module OpenTelemetry
|
|
81
81
|
def with_span(span)
|
82
82
|
Context.with_value(CURRENT_SPAN_KEY, span) { |c, s| yield s, c }
|
83
83
|
end
|
84
|
+
|
85
|
+
# Wraps a SpanContext with an object implementing the Span interface. This is done in order
|
86
|
+
# to expose a SpanContext as a Span in operations such as in-process Span propagation.
|
87
|
+
#
|
88
|
+
# @param [SpanContext] span_context SpanContext to be wrapped
|
89
|
+
#
|
90
|
+
# @return [Span]
|
91
|
+
def non_recording_span(span_context)
|
92
|
+
Span.new(span_context: span_context)
|
93
|
+
end
|
84
94
|
end
|
85
95
|
end
|
86
96
|
|
@@ -8,7 +8,7 @@ module OpenTelemetry
|
|
8
8
|
module Trace
|
9
9
|
module Propagation
|
10
10
|
module TraceContext
|
11
|
-
# Propagates
|
11
|
+
# Propagates trace context using the W3C Trace Context format
|
12
12
|
class TextMapPropagator
|
13
13
|
TRACEPARENT_KEY = 'traceparent'
|
14
14
|
TRACESTATE_KEY = 'tracestate'
|
@@ -53,7 +53,7 @@ module OpenTelemetry
|
|
53
53
|
trace_flags: tp.flags,
|
54
54
|
tracestate: tracestate,
|
55
55
|
remote: true)
|
56
|
-
span = Trace
|
56
|
+
span = OpenTelemetry::Trace.non_recording_span(span_context)
|
57
57
|
OpenTelemetry::Trace.context_with_span(span)
|
58
58
|
rescue OpenTelemetry::Error
|
59
59
|
context
|
@@ -4,15 +4,41 @@
|
|
4
4
|
#
|
5
5
|
# SPDX-License-Identifier: Apache-2.0
|
6
6
|
|
7
|
-
require 'opentelemetry/trace/util/http_to_status'
|
8
|
-
|
9
7
|
module OpenTelemetry
|
10
8
|
module Trace
|
11
9
|
# Status represents the status of a finished {Span}. It is composed of a
|
12
10
|
# status code in conjunction with an optional descriptive message.
|
13
11
|
class Status
|
14
|
-
|
15
|
-
|
12
|
+
class << self
|
13
|
+
private :new # rubocop:disable Style/AccessModifierDeclarations
|
14
|
+
|
15
|
+
# Returns a newly created {Status} with code == UNSET and an optional
|
16
|
+
# description.
|
17
|
+
#
|
18
|
+
# @param [String] description
|
19
|
+
# @return [Status]
|
20
|
+
def unset(description = '')
|
21
|
+
new(UNSET, description: description)
|
22
|
+
end
|
23
|
+
|
24
|
+
# Returns a newly created {Status} with code == OK and an optional
|
25
|
+
# description.
|
26
|
+
#
|
27
|
+
# @param [String] description
|
28
|
+
# @return [Status]
|
29
|
+
def ok(description = '')
|
30
|
+
new(OK, description: description)
|
31
|
+
end
|
32
|
+
|
33
|
+
# Returns a newly created {Status} with code == ERROR and an optional
|
34
|
+
# description.
|
35
|
+
#
|
36
|
+
# @param [String] description
|
37
|
+
# @return [Status]
|
38
|
+
def error(description = '')
|
39
|
+
new(ERROR, description: description)
|
40
|
+
end
|
41
|
+
end
|
16
42
|
|
17
43
|
# Retrieve the status code of this Status.
|
18
44
|
#
|
@@ -24,7 +50,10 @@ module OpenTelemetry
|
|
24
50
|
# @return [String]
|
25
51
|
attr_reader :description
|
26
52
|
|
27
|
-
#
|
53
|
+
# @api private
|
54
|
+
# The constructor is private and only for use internally by the class.
|
55
|
+
# Users should use the {unset}, {error}, or {ok} factory methods to
|
56
|
+
# obtain a {Status} instance.
|
28
57
|
#
|
29
58
|
# @param [Integer] code One of the status codes below
|
30
59
|
# @param [String] description
|
@@ -29,15 +29,14 @@ module OpenTelemetry
|
|
29
29
|
Trace.with_span(span) { |s, c| yield s, c }
|
30
30
|
rescue Exception => e # rubocop:disable Lint/RescueException
|
31
31
|
span&.record_exception(e)
|
32
|
-
span&.status = Status.
|
33
|
-
description: "Unhandled exception of type: #{e.class}")
|
32
|
+
span&.status = Status.error("Unhandled exception of type: #{e.class}")
|
34
33
|
raise e
|
35
34
|
ensure
|
36
35
|
span&.finish
|
37
36
|
end
|
38
37
|
|
39
38
|
def start_root_span(name, attributes: nil, links: nil, start_timestamp: nil, kind: nil)
|
40
|
-
Span
|
39
|
+
Span::INVALID
|
41
40
|
end
|
42
41
|
|
43
42
|
# Used when a caller wants to manage the activation/deactivation and lifecycle of
|
@@ -49,12 +48,12 @@ module OpenTelemetry
|
|
49
48
|
#
|
50
49
|
# @return [Span]
|
51
50
|
def start_span(name, with_parent: nil, attributes: nil, links: nil, start_timestamp: nil, kind: nil)
|
52
|
-
|
51
|
+
span = OpenTelemetry::Trace.current_span(with_parent)
|
53
52
|
|
54
|
-
if
|
55
|
-
|
53
|
+
if span.context.valid?
|
54
|
+
span
|
56
55
|
else
|
57
|
-
Span
|
56
|
+
Span::INVALID
|
58
57
|
end
|
59
58
|
end
|
60
59
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opentelemetry-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.rc2
|
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-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: benchmark-ipsa
|
@@ -152,9 +152,6 @@ files:
|
|
152
152
|
- lib/opentelemetry/baggage.rb
|
153
153
|
- lib/opentelemetry/baggage/builder.rb
|
154
154
|
- lib/opentelemetry/baggage/entry.rb
|
155
|
-
- lib/opentelemetry/baggage/manager.rb
|
156
|
-
- lib/opentelemetry/baggage/noop_builder.rb
|
157
|
-
- lib/opentelemetry/baggage/noop_manager.rb
|
158
155
|
- lib/opentelemetry/baggage/propagation.rb
|
159
156
|
- lib/opentelemetry/baggage/propagation/context_keys.rb
|
160
157
|
- lib/opentelemetry/baggage/propagation/text_map_propagator.rb
|
@@ -185,16 +182,15 @@ files:
|
|
185
182
|
- lib/opentelemetry/trace/tracer.rb
|
186
183
|
- lib/opentelemetry/trace/tracer_provider.rb
|
187
184
|
- lib/opentelemetry/trace/tracestate.rb
|
188
|
-
- lib/opentelemetry/trace/util/http_to_status.rb
|
189
185
|
- lib/opentelemetry/version.rb
|
190
186
|
homepage: https://github.com/open-telemetry/opentelemetry-ruby
|
191
187
|
licenses:
|
192
188
|
- Apache-2.0
|
193
189
|
metadata:
|
194
|
-
changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-api/v1.0.0.
|
190
|
+
changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-api/v1.0.0.rc2/file.CHANGELOG.html
|
195
191
|
source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/api
|
196
192
|
bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby/issues
|
197
|
-
documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-api/v1.0.0.
|
193
|
+
documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-api/v1.0.0.rc2
|
198
194
|
post_install_message:
|
199
195
|
rdoc_options: []
|
200
196
|
require_paths:
|
@@ -1,104 +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 Baggage
|
9
|
-
# Operational Baggage Manager implementation
|
10
|
-
class Manager
|
11
|
-
BAGGAGE_KEY = OpenTelemetry::Baggage::Propagation::ContextKeys.baggage_key
|
12
|
-
EMPTY_BAGGAGE = {}.freeze
|
13
|
-
private_constant(:BAGGAGE_KEY, :EMPTY_BAGGAGE)
|
14
|
-
|
15
|
-
# Used to chain modifications to baggage. The result is a
|
16
|
-
# context with an updated baggage. If only a single
|
17
|
-
# modification is being made to baggage, use the other
|
18
|
-
# methods on +Manager+, if multiple modifications are being made, use
|
19
|
-
# this one.
|
20
|
-
#
|
21
|
-
# @param [optional Context] context The context to update with with new
|
22
|
-
# modified baggage. Defaults to +Context.current+
|
23
|
-
# @return [Context]
|
24
|
-
def build(context: Context.current)
|
25
|
-
builder = Builder.new(baggage_for(context).dup)
|
26
|
-
yield builder
|
27
|
-
context.set_value(BAGGAGE_KEY, builder.entries)
|
28
|
-
end
|
29
|
-
|
30
|
-
# Returns a new context with empty baggage
|
31
|
-
#
|
32
|
-
# @param [optional Context] context Context to clear baggage from. Defaults
|
33
|
-
# to +Context.current+
|
34
|
-
# @return [Context]
|
35
|
-
def clear(context: Context.current)
|
36
|
-
context.set_value(BAGGAGE_KEY, EMPTY_BAGGAGE)
|
37
|
-
end
|
38
|
-
|
39
|
-
# Returns the corresponding baggage.entry (or nil) for key
|
40
|
-
#
|
41
|
-
# @param [String] key The lookup key
|
42
|
-
# @param [optional Context] context The context from which to retrieve
|
43
|
-
# the key.
|
44
|
-
# Defaults to +Context.current+
|
45
|
-
# @return [String]
|
46
|
-
def value(key, context: Context.current)
|
47
|
-
baggage_for(context)[key]&.value
|
48
|
-
end
|
49
|
-
|
50
|
-
# Returns the baggage
|
51
|
-
#
|
52
|
-
# @param [optional Context] context The context from which to retrieve
|
53
|
-
# the baggage.
|
54
|
-
# Defaults to +Context.current+
|
55
|
-
# @return [Hash]
|
56
|
-
def values(context: Context.current)
|
57
|
-
baggage_for(context).transform_values(&:value)
|
58
|
-
end
|
59
|
-
|
60
|
-
# @api private
|
61
|
-
def raw_entries(context: Context.current)
|
62
|
-
baggage_for(context).dup.freeze
|
63
|
-
end
|
64
|
-
|
65
|
-
# Returns a new context with new key-value pair
|
66
|
-
#
|
67
|
-
# @param [String] key The key to store this value under
|
68
|
-
# @param [String] value String value to be stored under key
|
69
|
-
# @param [optional String] metadata This is here to store properties
|
70
|
-
# received from other W3C Baggage impelmentations but is not exposed in
|
71
|
-
# OpenTelemetry. This is condsidered private API and not for use by
|
72
|
-
# end-users.
|
73
|
-
# @param [optional Context] context The context to update with new
|
74
|
-
# value. Defaults to +Context.current+
|
75
|
-
# @return [Context]
|
76
|
-
def set_value(key, value, metadata: nil, context: Context.current)
|
77
|
-
new_baggage = baggage_for(context).dup
|
78
|
-
new_baggage[key] = Entry.new(value, metadata)
|
79
|
-
context.set_value(BAGGAGE_KEY, new_baggage)
|
80
|
-
end
|
81
|
-
|
82
|
-
# Returns a new context with value at key removed
|
83
|
-
#
|
84
|
-
# @param [String] key The key to remove
|
85
|
-
# @param [optional Context] context The context to remove baggage
|
86
|
-
# from. Defaults to +Context.current+
|
87
|
-
# @return [Context]
|
88
|
-
def remove_value(key, context: Context.current)
|
89
|
-
baggage = baggage_for(context)
|
90
|
-
return context unless baggage.key?(key)
|
91
|
-
|
92
|
-
new_baggage = baggage.dup
|
93
|
-
new_baggage.delete(key)
|
94
|
-
context.set_value(BAGGAGE_KEY, new_baggage)
|
95
|
-
end
|
96
|
-
|
97
|
-
private
|
98
|
-
|
99
|
-
def baggage_for(context)
|
100
|
-
context.value(BAGGAGE_KEY) || EMPTY_BAGGAGE
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
@@ -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 Baggage
|
9
|
-
# No op implementation of Baggage::Builder
|
10
|
-
class NoopBuilder
|
11
|
-
def set_value(key, value, metadata: nil); end
|
12
|
-
|
13
|
-
def remove_value(key); end
|
14
|
-
|
15
|
-
def clear; end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,45 +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 Baggage
|
9
|
-
# No op implementation of Baggage::Manager
|
10
|
-
class NoopManager
|
11
|
-
NOOP_BUILDER = NoopBuilder.new
|
12
|
-
EMPTY_HASH = {}.freeze
|
13
|
-
private_constant(:NOOP_BUILDER, :EMPTY_HASH)
|
14
|
-
|
15
|
-
def build(context: Context.current)
|
16
|
-
yield NOOP_BUILDER
|
17
|
-
context
|
18
|
-
end
|
19
|
-
|
20
|
-
def set_value(key, value, metadata: nil, context: Context.current)
|
21
|
-
context
|
22
|
-
end
|
23
|
-
|
24
|
-
def value(key, context: Context.current)
|
25
|
-
nil
|
26
|
-
end
|
27
|
-
|
28
|
-
def values(context: Context.current)
|
29
|
-
EMPTY_HASH
|
30
|
-
end
|
31
|
-
|
32
|
-
def raw_entries(context: Context.current)
|
33
|
-
EMPTY_HASH
|
34
|
-
end
|
35
|
-
|
36
|
-
def remove_value(key, context: Context.current)
|
37
|
-
context
|
38
|
-
end
|
39
|
-
|
40
|
-
def clear(context: Context.current)
|
41
|
-
context
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,28 +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 Trace
|
9
|
-
module Util
|
10
|
-
# Convenience methods, not necessarily required by the API specification.
|
11
|
-
module HttpToStatus
|
12
|
-
# Maps numeric HTTP status codes to Trace::Status. This module is a mixin for Trace::Status
|
13
|
-
# and is not intended for standalone use.
|
14
|
-
#
|
15
|
-
# @param code Numeric HTTP status
|
16
|
-
# @return Status
|
17
|
-
def http_to_status(code)
|
18
|
-
case code.to_i
|
19
|
-
when 100..399
|
20
|
-
new(const_get(:OK))
|
21
|
-
else
|
22
|
-
new(const_get(:ERROR))
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|