opentelemetry-api 0.13.0 → 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 +40 -0
- data/README.md +2 -2
- data/lib/opentelemetry.rb +24 -20
- data/lib/opentelemetry/baggage.rb +4 -1
- data/lib/opentelemetry/baggage/builder.rb +30 -4
- data/lib/opentelemetry/baggage/entry.rb +20 -0
- data/lib/opentelemetry/baggage/manager.rb +76 -13
- data/lib/opentelemetry/baggage/noop_builder.rb +18 -0
- data/lib/opentelemetry/baggage/noop_manager.rb +45 -0
- data/lib/opentelemetry/baggage/propagation.rb +9 -38
- data/lib/opentelemetry/baggage/propagation/text_map_propagator.rb +109 -0
- data/lib/opentelemetry/context/propagation.rb +62 -7
- data/lib/opentelemetry/context/propagation/composite_text_map_propagator.rb +105 -0
- data/lib/opentelemetry/context/propagation/noop_text_map_propagator.rb +51 -0
- data/lib/opentelemetry/context/propagation/rack_env_getter.rb +48 -0
- data/lib/opentelemetry/context/propagation/text_map_getter.rb +27 -0
- data/lib/opentelemetry/context/propagation/text_map_propagator.rb +71 -0
- data/lib/opentelemetry/context/propagation/text_map_setter.rb +21 -0
- data/lib/opentelemetry/internal.rb +17 -0
- data/lib/opentelemetry/internal/proxy_tracer.rb +38 -0
- data/lib/opentelemetry/internal/proxy_tracer_provider.rb +59 -0
- data/lib/opentelemetry/trace/propagation/trace_context.rb +7 -37
- data/lib/opentelemetry/trace/propagation/trace_context/text_map_propagator.rb +73 -0
- data/lib/opentelemetry/trace/span.rb +20 -0
- data/lib/opentelemetry/trace/tracer.rb +2 -2
- data/lib/opentelemetry/version.rb +1 -1
- metadata +21 -26
- data/lib/opentelemetry/baggage/propagation/text_map_extractor.rb +0 -60
- data/lib/opentelemetry/baggage/propagation/text_map_injector.rb +0 -55
- data/lib/opentelemetry/context/propagation/composite_propagator.rb +0 -73
- data/lib/opentelemetry/context/propagation/default_getter.rb +0 -26
- data/lib/opentelemetry/context/propagation/default_setter.rb +0 -26
- data/lib/opentelemetry/context/propagation/noop_extractor.rb +0 -26
- data/lib/opentelemetry/context/propagation/noop_injector.rb +0 -26
- data/lib/opentelemetry/context/propagation/propagation.rb +0 -27
- data/lib/opentelemetry/context/propagation/propagator.rb +0 -64
- data/lib/opentelemetry/instrumentation.rb +0 -15
- data/lib/opentelemetry/instrumentation/base.rb +0 -245
- data/lib/opentelemetry/instrumentation/registry.rb +0 -86
- data/lib/opentelemetry/metrics.rb +0 -16
- data/lib/opentelemetry/metrics/handles.rb +0 -44
- data/lib/opentelemetry/metrics/instruments.rb +0 -105
- data/lib/opentelemetry/metrics/meter.rb +0 -72
- data/lib/opentelemetry/metrics/meter_provider.rb +0 -22
- data/lib/opentelemetry/trace/propagation/trace_context/text_map_extractor.rb +0 -57
- data/lib/opentelemetry/trace/propagation/trace_context/text_map_injector.rb +0 -54
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright The OpenTelemetry Authors
|
4
|
+
#
|
5
|
+
# SPDX-License-Identifier: Apache-2.0
|
6
|
+
|
7
|
+
module OpenTelemetry
|
8
|
+
class Context
|
9
|
+
module Propagation
|
10
|
+
# The default setter module provides a common method for writing
|
11
|
+
# a key into a carrier that implements +[]=+
|
12
|
+
class TextMapSetter
|
13
|
+
# Writes key into a carrier that implements +[]=+. Useful for inject
|
14
|
+
# operations.
|
15
|
+
def set(carrier, key, value)
|
16
|
+
carrier[key] = value
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright The OpenTelemetry Authors
|
4
|
+
#
|
5
|
+
# SPDX-License-Identifier: Apache-2.0
|
6
|
+
|
7
|
+
require 'opentelemetry/internal/proxy_tracer'
|
8
|
+
require 'opentelemetry/internal/proxy_tracer_provider'
|
9
|
+
|
10
|
+
module OpenTelemetry
|
11
|
+
# @api private
|
12
|
+
#
|
13
|
+
# The Internal module provides API internal functionality that is not a part of the
|
14
|
+
# public API.
|
15
|
+
module Internal
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,38 @@
|
|
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 Internal
|
9
|
+
# @api private
|
10
|
+
#
|
11
|
+
# {ProxyTracer} is an implementation of {OpenTelemetry::Trace::Tracer}. It is returned from
|
12
|
+
# the ProxyTracerProvider until a delegate tracer provider is installed. After the delegate
|
13
|
+
# tracer provider is installed, the ProxyTracer will delegate to the corresponding "real"
|
14
|
+
# tracer.
|
15
|
+
class ProxyTracer < Trace::Tracer
|
16
|
+
attr_writer :delegate
|
17
|
+
|
18
|
+
# Returns a new {ProxyTracer} instance.
|
19
|
+
#
|
20
|
+
# @return [ProxyTracer]
|
21
|
+
def initialize
|
22
|
+
@delegate = nil
|
23
|
+
end
|
24
|
+
|
25
|
+
def start_root_span(name, attributes: nil, links: nil, start_timestamp: nil, kind: nil)
|
26
|
+
return @delegate.start_root_span(name, attributes: attributes, links: links, start_timestamp: start_timestamp, kind: kind) unless @delegate.nil?
|
27
|
+
|
28
|
+
super
|
29
|
+
end
|
30
|
+
|
31
|
+
def start_span(name, with_parent: nil, attributes: nil, links: nil, start_timestamp: nil, kind: nil)
|
32
|
+
return @delegate.start_span(name, with_parent: with_parent, attributes: attributes, links: links, start_timestamp: start_timestamp, kind: kind) unless @delegate.nil?
|
33
|
+
|
34
|
+
super
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,59 @@
|
|
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 Internal
|
9
|
+
# @api private
|
10
|
+
#
|
11
|
+
# {ProxyTracerProvider} is an implementation of {OpenTelemetry::Trace::TracerProvider}.
|
12
|
+
# It is the default global tracer provider returned by OpenTelemetry.tracer_provider.
|
13
|
+
# It delegates to a "real" TracerProvider after the global tracer provider is registered.
|
14
|
+
# It returns {ProxyTracer} instances until the delegate is installed.
|
15
|
+
class ProxyTracerProvider < Trace::TracerProvider
|
16
|
+
Key = Struct.new(:name, :version)
|
17
|
+
private_constant(:Key)
|
18
|
+
|
19
|
+
# Returns a new {ProxyTracerProvider} instance.
|
20
|
+
#
|
21
|
+
# @return [ProxyTracerProvider]
|
22
|
+
def initialize
|
23
|
+
@mutex = Mutex.new
|
24
|
+
@registry = {}
|
25
|
+
@delegate = nil
|
26
|
+
end
|
27
|
+
|
28
|
+
# Set the delegate tracer provider. If this is called more than once, a warning will
|
29
|
+
# be logged and superfluous calls will be ignored.
|
30
|
+
#
|
31
|
+
# @param [TracerProvider] provider The tracer provider to delegate to
|
32
|
+
def delegate=(provider)
|
33
|
+
unless @delegate.nil?
|
34
|
+
OpenTelemetry.logger.warn 'Attempt to reset delegate in ProxyTracerProvider ignored.'
|
35
|
+
return
|
36
|
+
end
|
37
|
+
|
38
|
+
@mutex.synchronize do
|
39
|
+
@delegate = provider
|
40
|
+
@registry.each { |key, tracer| tracer.delegate = provider.tracer(key.name, key.version) }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# Returns a {Tracer} instance.
|
45
|
+
#
|
46
|
+
# @param [optional String] name Instrumentation package name
|
47
|
+
# @param [optional String] version Instrumentation package version
|
48
|
+
#
|
49
|
+
# @return [Tracer]
|
50
|
+
def tracer(name = nil, version = nil)
|
51
|
+
@mutex.synchronize do
|
52
|
+
return @delegate.tracer(name, version) unless @delegate.nil?
|
53
|
+
|
54
|
+
@registry[Key.new(name, version)] ||= ProxyTracer.new
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -5,8 +5,7 @@
|
|
5
5
|
# SPDX-License-Identifier: Apache-2.0
|
6
6
|
|
7
7
|
require 'opentelemetry/trace/propagation/trace_context/trace_parent'
|
8
|
-
require 'opentelemetry/trace/propagation/trace_context/
|
9
|
-
require 'opentelemetry/trace/propagation/trace_context/text_map_injector'
|
8
|
+
require 'opentelemetry/trace/propagation/trace_context/text_map_propagator'
|
10
9
|
|
11
10
|
module OpenTelemetry
|
12
11
|
module Trace
|
@@ -15,43 +14,14 @@ module OpenTelemetry
|
|
15
14
|
# for context propagation in the W3C Trace Context format.
|
16
15
|
module TraceContext
|
17
16
|
extend self
|
17
|
+
TEXT_MAP_PROPAGATOR = TextMapPropagator.new
|
18
18
|
|
19
|
-
|
20
|
-
TEXT_MAP_INJECTOR = TextMapInjector.new
|
21
|
-
RACK_EXTRACTOR = TextMapExtractor.new(
|
22
|
-
traceparent_key: 'HTTP_TRACEPARENT',
|
23
|
-
tracestate_key: 'HTTP_TRACESTATE'
|
24
|
-
)
|
25
|
-
RACK_INJECTOR = TextMapInjector.new(
|
26
|
-
traceparent_key: 'HTTP_TRACEPARENT',
|
27
|
-
tracestate_key: 'HTTP_TRACESTATE'
|
28
|
-
)
|
19
|
+
private_constant :TEXT_MAP_PROPAGATOR
|
29
20
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
# format
|
35
|
-
def text_map_extractor
|
36
|
-
TEXT_MAP_EXTRACTOR
|
37
|
-
end
|
38
|
-
|
39
|
-
# Returns an injector that injects context using the W3C Trace Context
|
40
|
-
# format
|
41
|
-
def text_map_injector
|
42
|
-
TEXT_MAP_INJECTOR
|
43
|
-
end
|
44
|
-
|
45
|
-
# Returns an extractor that extracts context using the W3C Trace Context
|
46
|
-
# with Rack normalized keys (upcased and prefixed with HTTP_)
|
47
|
-
def rack_extractor
|
48
|
-
RACK_EXTRACTOR
|
49
|
-
end
|
50
|
-
|
51
|
-
# Returns an injector that injects context using the W3C Trace Context
|
52
|
-
# format with Rack normalized keys (upcased and prefixed with HTTP_)
|
53
|
-
def rack_injector
|
54
|
-
RACK_INJECTOR
|
21
|
+
# Returns a text map propagator that propagates context using the
|
22
|
+
# W3C Trace Context format.
|
23
|
+
def text_map_propagator
|
24
|
+
TEXT_MAP_PROPAGATOR
|
55
25
|
end
|
56
26
|
end
|
57
27
|
end
|
@@ -0,0 +1,73 @@
|
|
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 Propagation
|
10
|
+
module TraceContext
|
11
|
+
# Propagates baggage using the W3C Trace Context format
|
12
|
+
class TextMapPropagator
|
13
|
+
TRACEPARENT_KEY = 'traceparent'
|
14
|
+
TRACESTATE_KEY = 'tracestate'
|
15
|
+
FIELDS = [TRACEPARENT_KEY, TRACESTATE_KEY].freeze
|
16
|
+
|
17
|
+
private_constant :TRACEPARENT_KEY, :TRACESTATE_KEY, :FIELDS
|
18
|
+
|
19
|
+
# Inject trace context into the supplied carrier.
|
20
|
+
#
|
21
|
+
# @param [Carrier] carrier The mutable carrier to inject trace context into
|
22
|
+
# @param [Context] context The context to read trace context from
|
23
|
+
# @param [optional Setter] setter If the optional setter is provided, it
|
24
|
+
# will be used to write context into the carrier, otherwise the default
|
25
|
+
# text map setter will be used.
|
26
|
+
def inject(carrier, context: Context.current, setter: Context::Propagation.text_map_setter)
|
27
|
+
span_context = Trace.current_span(context).context
|
28
|
+
return unless span_context.valid?
|
29
|
+
|
30
|
+
setter.set(carrier, TRACEPARENT_KEY, TraceParent.from_span_context(span_context).to_s)
|
31
|
+
setter.set(carrier, TRACESTATE_KEY, span_context.tracestate.to_s) unless span_context.tracestate.empty?
|
32
|
+
nil
|
33
|
+
end
|
34
|
+
|
35
|
+
# Extract trace context from the supplied carrier.
|
36
|
+
# If extraction fails, the original context will be returned
|
37
|
+
#
|
38
|
+
# @param [Carrier] carrier The carrier to get the header from
|
39
|
+
# @param [optional Context] context Context to be updated with the trace context
|
40
|
+
# extracted from the carrier. Defaults to +Context.current+.
|
41
|
+
# @param [optional Getter] getter If the optional getter is provided, it
|
42
|
+
# will be used to read the header from the carrier, otherwise the default
|
43
|
+
# text map getter will be used.
|
44
|
+
#
|
45
|
+
# @return [Context] context updated with extracted baggage, or the original context
|
46
|
+
# if extraction fails
|
47
|
+
def extract(carrier, context: Context.current, getter: Context::Propagation.text_map_getter)
|
48
|
+
tp = TraceParent.from_string(getter.get(carrier, TRACEPARENT_KEY))
|
49
|
+
tracestate = Tracestate.from_string(getter.get(carrier, TRACESTATE_KEY))
|
50
|
+
|
51
|
+
span_context = Trace::SpanContext.new(trace_id: tp.trace_id,
|
52
|
+
span_id: tp.span_id,
|
53
|
+
trace_flags: tp.flags,
|
54
|
+
tracestate: tracestate,
|
55
|
+
remote: true)
|
56
|
+
span = Trace::Span.new(span_context: span_context)
|
57
|
+
OpenTelemetry::Trace.context_with_span(span)
|
58
|
+
rescue OpenTelemetry::Error
|
59
|
+
context
|
60
|
+
end
|
61
|
+
|
62
|
+
# Returns the predefined propagation fields. If your carrier is reused, you
|
63
|
+
# should delete the fields returned by this method before calling +inject+.
|
64
|
+
#
|
65
|
+
# @return [Array<String>] a list of fields that will be used by this propagator.
|
66
|
+
def fields
|
67
|
+
FIELDS
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -51,6 +51,9 @@ module OpenTelemetry
|
|
51
51
|
#
|
52
52
|
# @param [String] key
|
53
53
|
# @param [String, Boolean, Numeric, Array<String, Numeric, Boolean>] value
|
54
|
+
# Values must be non-nil and (array of) string, boolean or numeric type.
|
55
|
+
# Array values must not contain nil elements and all elements must be of
|
56
|
+
# the same basic type (string, numeric, boolean).
|
54
57
|
#
|
55
58
|
# @return [self] returns itself
|
56
59
|
def set_attribute(key, value)
|
@@ -58,6 +61,23 @@ module OpenTelemetry
|
|
58
61
|
end
|
59
62
|
alias []= set_attribute
|
60
63
|
|
64
|
+
# Add attributes
|
65
|
+
#
|
66
|
+
# Note that the OpenTelemetry project
|
67
|
+
# {https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/data-semantic-conventions.md
|
68
|
+
# documents} certain "standard attributes" that have prescribed semantic
|
69
|
+
# meanings.
|
70
|
+
#
|
71
|
+
# @param [Hash{String => String, Numeric, Boolean, Array<String, Numeric, Boolean>}] attributes
|
72
|
+
# Values must be non-nil and (array of) string, boolean or numeric type.
|
73
|
+
# Array values must not contain nil elements and all elements must be of
|
74
|
+
# the same basic type (string, numeric, boolean).
|
75
|
+
#
|
76
|
+
# @return [self] returns itself
|
77
|
+
def add_attributes(attributes)
|
78
|
+
self
|
79
|
+
end
|
80
|
+
|
61
81
|
# Add an event to a {Span}.
|
62
82
|
#
|
63
83
|
# Example:
|
@@ -23,9 +23,9 @@ module OpenTelemetry
|
|
23
23
|
# span and reraised.
|
24
24
|
# @yield [span, context] yields the newly created span and a context containing the
|
25
25
|
# span to the block.
|
26
|
-
def in_span(name, attributes: nil, links: nil, start_timestamp: nil, kind: nil
|
26
|
+
def in_span(name, attributes: nil, links: nil, start_timestamp: nil, kind: nil)
|
27
27
|
span = nil
|
28
|
-
span = start_span(name, attributes: attributes, links: links, start_timestamp: start_timestamp, kind: kind
|
28
|
+
span = start_span(name, attributes: attributes, links: links, start_timestamp: start_timestamp, kind: kind)
|
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)
|
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: 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: benchmark-ipsa
|
@@ -151,36 +151,31 @@ files:
|
|
151
151
|
- lib/opentelemetry.rb
|
152
152
|
- lib/opentelemetry/baggage.rb
|
153
153
|
- lib/opentelemetry/baggage/builder.rb
|
154
|
+
- lib/opentelemetry/baggage/entry.rb
|
154
155
|
- lib/opentelemetry/baggage/manager.rb
|
156
|
+
- lib/opentelemetry/baggage/noop_builder.rb
|
157
|
+
- lib/opentelemetry/baggage/noop_manager.rb
|
155
158
|
- lib/opentelemetry/baggage/propagation.rb
|
156
159
|
- lib/opentelemetry/baggage/propagation/context_keys.rb
|
157
|
-
- lib/opentelemetry/baggage/propagation/
|
158
|
-
- lib/opentelemetry/baggage/propagation/text_map_injector.rb
|
160
|
+
- lib/opentelemetry/baggage/propagation/text_map_propagator.rb
|
159
161
|
- lib/opentelemetry/context.rb
|
160
162
|
- lib/opentelemetry/context/key.rb
|
161
163
|
- lib/opentelemetry/context/propagation.rb
|
162
|
-
- lib/opentelemetry/context/propagation/
|
163
|
-
- lib/opentelemetry/context/propagation/
|
164
|
-
- lib/opentelemetry/context/propagation/
|
165
|
-
- lib/opentelemetry/context/propagation/
|
166
|
-
- lib/opentelemetry/context/propagation/
|
167
|
-
- lib/opentelemetry/context/propagation/
|
168
|
-
- lib/opentelemetry/context/propagation/propagator.rb
|
164
|
+
- lib/opentelemetry/context/propagation/composite_text_map_propagator.rb
|
165
|
+
- lib/opentelemetry/context/propagation/noop_text_map_propagator.rb
|
166
|
+
- lib/opentelemetry/context/propagation/rack_env_getter.rb
|
167
|
+
- lib/opentelemetry/context/propagation/text_map_getter.rb
|
168
|
+
- lib/opentelemetry/context/propagation/text_map_propagator.rb
|
169
|
+
- lib/opentelemetry/context/propagation/text_map_setter.rb
|
169
170
|
- lib/opentelemetry/error.rb
|
170
|
-
- lib/opentelemetry/
|
171
|
-
- lib/opentelemetry/
|
172
|
-
- lib/opentelemetry/
|
173
|
-
- lib/opentelemetry/metrics.rb
|
174
|
-
- lib/opentelemetry/metrics/handles.rb
|
175
|
-
- lib/opentelemetry/metrics/instruments.rb
|
176
|
-
- lib/opentelemetry/metrics/meter.rb
|
177
|
-
- lib/opentelemetry/metrics/meter_provider.rb
|
171
|
+
- lib/opentelemetry/internal.rb
|
172
|
+
- lib/opentelemetry/internal/proxy_tracer.rb
|
173
|
+
- lib/opentelemetry/internal/proxy_tracer_provider.rb
|
178
174
|
- lib/opentelemetry/trace.rb
|
179
175
|
- lib/opentelemetry/trace/link.rb
|
180
176
|
- lib/opentelemetry/trace/propagation.rb
|
181
177
|
- lib/opentelemetry/trace/propagation/trace_context.rb
|
182
|
-
- lib/opentelemetry/trace/propagation/trace_context/
|
183
|
-
- lib/opentelemetry/trace/propagation/trace_context/text_map_injector.rb
|
178
|
+
- lib/opentelemetry/trace/propagation/trace_context/text_map_propagator.rb
|
184
179
|
- lib/opentelemetry/trace/propagation/trace_context/trace_parent.rb
|
185
180
|
- lib/opentelemetry/trace/span.rb
|
186
181
|
- lib/opentelemetry/trace/span_context.rb
|
@@ -196,10 +191,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby
|
|
196
191
|
licenses:
|
197
192
|
- Apache-2.0
|
198
193
|
metadata:
|
199
|
-
changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-api/
|
194
|
+
changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-api/v1.0.0.rc1/file.CHANGELOG.html
|
200
195
|
source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/api
|
201
196
|
bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby/issues
|
202
|
-
documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-api/
|
197
|
+
documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-api/v1.0.0.rc1
|
203
198
|
post_install_message:
|
204
199
|
rdoc_options: []
|
205
200
|
require_paths:
|
@@ -211,11 +206,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
211
206
|
version: 2.5.0
|
212
207
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
213
208
|
requirements:
|
214
|
-
- - "
|
209
|
+
- - ">"
|
215
210
|
- !ruby/object:Gem::Version
|
216
|
-
version:
|
211
|
+
version: 1.3.1
|
217
212
|
requirements: []
|
218
|
-
rubygems_version: 3.1.
|
213
|
+
rubygems_version: 3.1.6
|
219
214
|
signing_key:
|
220
215
|
specification_version: 4
|
221
216
|
summary: A stats collection and distributed tracing framework
|
@@ -1,60 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright The OpenTelemetry Authors
|
4
|
-
#
|
5
|
-
# SPDX-License-Identifier: Apache-2.0
|
6
|
-
|
7
|
-
require 'cgi'
|
8
|
-
|
9
|
-
module OpenTelemetry
|
10
|
-
module Baggage
|
11
|
-
module Propagation
|
12
|
-
# Extracts baggage from carriers in the W3C Baggage format
|
13
|
-
class TextMapExtractor
|
14
|
-
include Context::Propagation::DefaultGetter
|
15
|
-
|
16
|
-
# Returns a new TextMapExtractor that extracts context using the specified
|
17
|
-
# header key
|
18
|
-
#
|
19
|
-
# @param [String] baggage_key The baggage header
|
20
|
-
# key used in the carrier
|
21
|
-
# @return [TextMapExtractor]
|
22
|
-
def initialize(baggage_key: 'baggage')
|
23
|
-
@baggage_key = baggage_key
|
24
|
-
end
|
25
|
-
|
26
|
-
# Extract remote baggage from the supplied carrier.
|
27
|
-
# If extraction fails, the original context will be returned
|
28
|
-
#
|
29
|
-
# @param [Carrier] carrier The carrier to get the header from
|
30
|
-
# @param [Context] context The context to be updated with extracted baggage
|
31
|
-
# @param [optional Callable] getter An optional callable that takes a carrier and a key and
|
32
|
-
# returns the value associated with the key. If omitted the default getter will be used
|
33
|
-
# which expects the carrier to respond to [] and []=.
|
34
|
-
# @yield [Carrier, String] if an optional getter is provided, extract will yield the carrier
|
35
|
-
# and the header key to the getter.
|
36
|
-
# @return [Context] context updated with extracted baggage, or the original context
|
37
|
-
# if extraction fails
|
38
|
-
def extract(carrier, context, &getter)
|
39
|
-
getter ||= default_getter
|
40
|
-
header = getter.call(carrier, @baggage_key)
|
41
|
-
|
42
|
-
entries = header.gsub(/\s/, '').split(',')
|
43
|
-
|
44
|
-
baggage = entries.each_with_object({}) do |entry, memo|
|
45
|
-
# The ignored variable below holds properties as per the W3C spec.
|
46
|
-
# OTel is not using them currently, but they might be used for
|
47
|
-
# metadata in the future
|
48
|
-
kv, = entry.split(';', 2)
|
49
|
-
k, v = kv.split('=').map!(&CGI.method(:unescape))
|
50
|
-
memo[k] = v
|
51
|
-
end
|
52
|
-
|
53
|
-
context.set_value(ContextKeys.baggage_key, baggage)
|
54
|
-
rescue StandardError
|
55
|
-
context
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|