opentelemetry-api 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +9 -0
- data/OVERVIEW.md +66 -0
- data/lib/{opentelemetry/distributed_context/manager.rb → opentelemetry-api.rb} +1 -6
- data/lib/opentelemetry.rb +34 -16
- data/lib/opentelemetry/context.rb +138 -15
- data/lib/opentelemetry/context/key.rb +29 -0
- data/lib/opentelemetry/context/propagation.rb +22 -0
- data/lib/opentelemetry/context/propagation/composite_propagator.rb +77 -0
- data/lib/opentelemetry/context/propagation/default_getter.rb +26 -0
- data/lib/opentelemetry/context/propagation/default_setter.rb +26 -0
- data/lib/opentelemetry/context/propagation/noop_extractor.rb +26 -0
- data/lib/opentelemetry/context/propagation/noop_injector.rb +26 -0
- data/lib/opentelemetry/context/propagation/propagation.rb +27 -0
- data/lib/opentelemetry/context/propagation/propagator.rb +64 -0
- data/lib/opentelemetry/correlation_context.rb +16 -0
- data/lib/opentelemetry/correlation_context/builder.rb +18 -0
- data/lib/opentelemetry/correlation_context/manager.rb +36 -0
- data/lib/opentelemetry/correlation_context/propagation.rb +57 -0
- data/lib/opentelemetry/correlation_context/propagation/context_keys.rb +27 -0
- data/lib/opentelemetry/correlation_context/propagation/text_extractor.rb +60 -0
- data/lib/opentelemetry/correlation_context/propagation/text_injector.rb +55 -0
- data/lib/opentelemetry/instrumentation.rb +15 -0
- data/lib/opentelemetry/instrumentation/adapter.rb +244 -0
- data/lib/opentelemetry/instrumentation/registry.rb +87 -0
- data/lib/opentelemetry/metrics.rb +1 -1
- data/lib/opentelemetry/metrics/handles.rb +5 -15
- data/lib/opentelemetry/metrics/instruments.rb +18 -69
- data/lib/opentelemetry/metrics/meter.rb +2 -39
- data/lib/opentelemetry/metrics/{meter_factory.rb → meter_provider.rb} +2 -2
- data/lib/opentelemetry/trace.rb +2 -2
- data/lib/opentelemetry/trace/event.rb +4 -3
- data/lib/opentelemetry/trace/link.rb +4 -3
- data/lib/opentelemetry/trace/propagation.rb +17 -0
- data/lib/opentelemetry/trace/propagation/context_keys.rb +35 -0
- data/lib/opentelemetry/trace/propagation/trace_context.rb +59 -0
- data/lib/opentelemetry/trace/propagation/trace_context/text_extractor.rb +58 -0
- data/lib/opentelemetry/trace/propagation/trace_context/text_injector.rb +55 -0
- data/lib/opentelemetry/trace/propagation/trace_context/trace_parent.rb +126 -0
- data/lib/opentelemetry/trace/span.rb +14 -6
- data/lib/opentelemetry/trace/status.rb +7 -2
- data/lib/opentelemetry/trace/tracer.rb +47 -13
- data/lib/opentelemetry/trace/tracer_provider.rb +22 -0
- data/lib/opentelemetry/trace/util/http_to_status.rb +47 -0
- data/lib/opentelemetry/version.rb +1 -1
- metadata +33 -13
- data/lib/opentelemetry/distributed_context.rb +0 -19
- data/lib/opentelemetry/distributed_context/distributed_context.rb +0 -24
- data/lib/opentelemetry/distributed_context/entry.rb +0 -66
- data/lib/opentelemetry/distributed_context/propagation.rb +0 -19
- data/lib/opentelemetry/distributed_context/propagation/binary_format.rb +0 -26
- data/lib/opentelemetry/distributed_context/propagation/text_format.rb +0 -76
- data/lib/opentelemetry/distributed_context/propagation/trace_parent.rb +0 -124
- data/lib/opentelemetry/trace/sampling_hint.rb +0 -22
- data/lib/opentelemetry/trace/tracer_factory.rb +0 -45
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c91a5540309be0f2dcc70066b25eab314bed537321a6d4b8360b72077cb9da22
|
4
|
+
data.tar.gz: 925121d6b30bf9cf3b1a17c30afbfdf5e328b0374b23a8daade2cf1d486e795f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93299563d90db1b05e873f431e151dc1d2e7e05f54d0b5311985be42d15a3f33f50e3e35fb24e0ef063a26a3cc06333bcb304ee418dd590ed124c08416735b80
|
7
|
+
data.tar.gz: e7edc0bde321596ec89fedc87c1209e35a6b306b22a87aa0e761a4a77cd3b4d9f0239a486f7444f280008c733e9a8378369cb0640fd60b58106bf256b9bd4e5c
|
data/.yardopts
ADDED
data/OVERVIEW.md
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
# opentelemetry-api
|
2
|
+
|
3
|
+
The `opentelemetry-api` gem defines the core OpenTelemetry interfaces for Ruby applications. Using `opentelemetry-api`, a library or application can code against the OpenTelemetry interfaces to produce telemetry data such as distributed traces and metrics.
|
4
|
+
|
5
|
+
## What is OpenTelemetry?
|
6
|
+
|
7
|
+
[OpenTelemetry][opentelemetry-home] is an open source observability framework, providing a general-purpose API, SDK, and related tools required for the instrumentation of cloud-native software, frameworks, and libraries.
|
8
|
+
|
9
|
+
OpenTelemetry provides a single set of APIs, libraries, agents, and collector services to capture distributed traces and metrics from your application. You can analyze them using Prometheus, Jaeger, and other observability tools.
|
10
|
+
|
11
|
+
## How does this gem fit in?
|
12
|
+
|
13
|
+
The `opentelemetry-api` gem defines the core OpenTelemetry interfaces in the form of abstract classes and no-op implementations. That is, it defines interfaces and data types sufficient for a library or application to code against to produce telemetry data, but does not actually collect, analyze, or export the data.
|
14
|
+
|
15
|
+
To collect and analyze telemetry data, *applications* should also install a concrete implementation of the API, such as the `opentelemetry-sdk` gem. However, *libraries* that produce telemetry data should depend only on `opentelemetry-api`, deferring the choise of concrete implementation to the application developer.
|
16
|
+
|
17
|
+
## How do I get started?
|
18
|
+
|
19
|
+
Install the gem using:
|
20
|
+
|
21
|
+
```
|
22
|
+
gem install opentelemetry-api
|
23
|
+
```
|
24
|
+
|
25
|
+
Or, if you use [bundler][bundler-home], include `opentelemetry-api` in your `Gemfile`.
|
26
|
+
|
27
|
+
Then, use the OpenTelemetry interfaces to produces traces and other telemetry data. Following is a basic example.
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
require 'opentelemetry'
|
31
|
+
|
32
|
+
# Obtain the current default tracer factory
|
33
|
+
factory = OpenTelemetry.tracer_factory
|
34
|
+
|
35
|
+
# Create a trace
|
36
|
+
tracer = factory.tracer('my_app', '1.0')
|
37
|
+
|
38
|
+
# Record spans
|
39
|
+
tracer.in_span('my_task') do |task_span|
|
40
|
+
tracer.in_span('inner') do |inner_span|
|
41
|
+
# Do something here
|
42
|
+
end
|
43
|
+
end
|
44
|
+
```
|
45
|
+
|
46
|
+
For additional examples, see the [examples on github][examples-github].
|
47
|
+
|
48
|
+
## How can I get involved?
|
49
|
+
|
50
|
+
The `opentelemetry-api` gem source is [on github][repo-github], along with related gems including `opentelemetry-sdk`.
|
51
|
+
|
52
|
+
The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us on our [gitter channel][ruby-gitter] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig].
|
53
|
+
|
54
|
+
## License
|
55
|
+
|
56
|
+
The `opentelemetry-api` gem is distributed under the Apache 2.0 license. See [LICENSE][license-github] for more information.
|
57
|
+
|
58
|
+
|
59
|
+
[opentelemetry-home]: https://opentelemetry.io
|
60
|
+
[bundler-home]: https://bundler.io
|
61
|
+
[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby
|
62
|
+
[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/master/LICENSE
|
63
|
+
[examples-github]: https://github.com/open-telemetry/opentelemetry-ruby/tree/master/examples
|
64
|
+
[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig
|
65
|
+
[community-meetings]: https://github.com/open-telemetry/community#community-meetings
|
66
|
+
[ruby-gitter]: https://gitter.im/open-telemetry/opentelemetry-ruby
|
data/lib/opentelemetry.rb
CHANGED
@@ -1,42 +1,60 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright
|
3
|
+
# Copyright 2020 OpenTelemetry Authors
|
4
4
|
#
|
5
5
|
# SPDX-License-Identifier: Apache-2.0
|
6
|
+
|
6
7
|
require 'logger'
|
7
8
|
|
8
9
|
require 'opentelemetry/error'
|
9
10
|
require 'opentelemetry/context'
|
10
|
-
require 'opentelemetry/
|
11
|
+
require 'opentelemetry/correlation_context'
|
11
12
|
require 'opentelemetry/internal'
|
13
|
+
require 'opentelemetry/instrumentation'
|
12
14
|
require 'opentelemetry/metrics'
|
13
15
|
require 'opentelemetry/trace'
|
14
16
|
require 'opentelemetry/version'
|
15
17
|
|
16
|
-
# OpenTelemetry
|
18
|
+
# OpenTelemetry is an open source observability framework, providing a
|
19
|
+
# general-purpose API, SDK, and related tools required for the instrumentation
|
20
|
+
# of cloud-native software, frameworks, and libraries.
|
21
|
+
#
|
22
|
+
# The OpenTelemetry module provides global accessors for telemetry objects.
|
17
23
|
module OpenTelemetry
|
18
24
|
extend self
|
19
25
|
|
20
|
-
attr_writer :
|
26
|
+
attr_writer :tracer_provider, :meter_provider, :correlations
|
21
27
|
|
22
28
|
attr_accessor :logger
|
23
29
|
|
24
|
-
# @return [Object, Trace::
|
25
|
-
# default no-op implementation of the tracer
|
26
|
-
def
|
27
|
-
@
|
30
|
+
# @return [Object, Trace::TracerProvider] registered tracer provider or a
|
31
|
+
# default no-op implementation of the tracer provider.
|
32
|
+
def tracer_provider
|
33
|
+
@tracer_provider ||= Trace::TracerProvider.new
|
34
|
+
end
|
35
|
+
|
36
|
+
# @return [Object, Metrics::MeterProvider] registered meter provider or a
|
37
|
+
# default no-op implementation of the meter provider.
|
38
|
+
def meter_provider
|
39
|
+
@meter_provider ||= Metrics::MeterProvider.new
|
40
|
+
end
|
41
|
+
|
42
|
+
# @return [Instrumentation::Registry] registry containing all known
|
43
|
+
# instrumentation
|
44
|
+
def instrumentation_registry
|
45
|
+
@instrumentation_registry ||= Instrumentation::Registry.new
|
28
46
|
end
|
29
47
|
|
30
|
-
# @return [Object,
|
31
|
-
# default no-op implementation of the
|
32
|
-
|
33
|
-
|
48
|
+
# @return [Object, CorrelationContext::Manager] registered
|
49
|
+
# correlation context manager or a default no-op implementation of the
|
50
|
+
# manager.
|
51
|
+
def correlations
|
52
|
+
@correlations ||= CorrelationContext::Manager.new
|
34
53
|
end
|
35
54
|
|
36
|
-
# @return [
|
37
|
-
|
38
|
-
|
39
|
-
@distributed_context_manager ||= DistributedContext::Manager.new
|
55
|
+
# @return [Context::Propagation::Propagation] an instance of the propagation API
|
56
|
+
def propagation
|
57
|
+
@propagation ||= Context::Propagation::Propagation.new
|
40
58
|
end
|
41
59
|
|
42
60
|
self.logger = Logger.new(STDOUT)
|
@@ -4,28 +4,151 @@
|
|
4
4
|
#
|
5
5
|
# SPDX-License-Identifier: Apache-2.0
|
6
6
|
|
7
|
+
require 'opentelemetry/context/key'
|
8
|
+
require 'opentelemetry/context/propagation'
|
9
|
+
|
7
10
|
module OpenTelemetry
|
8
|
-
#
|
9
|
-
|
10
|
-
|
11
|
+
# Manages context on a per-fiber basis
|
12
|
+
class Context
|
13
|
+
KEY = :__opentelemetry_context__
|
14
|
+
EMPTY_ENTRIES = {}.freeze
|
15
|
+
|
16
|
+
class << self
|
17
|
+
# Returns a key used to index a value in a Context
|
18
|
+
#
|
19
|
+
# @param [String] name The key name
|
20
|
+
# @return [Context::Key]
|
21
|
+
def create_key(name)
|
22
|
+
Key.new(name)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Returns current context, which is never nil
|
26
|
+
#
|
27
|
+
# @return [Context]
|
28
|
+
def current
|
29
|
+
Thread.current[KEY] ||= ROOT
|
30
|
+
end
|
31
|
+
|
32
|
+
# Sets the current context
|
33
|
+
#
|
34
|
+
# @param [Context] ctx The context to be made active
|
35
|
+
def current=(ctx)
|
36
|
+
Thread.current[KEY] = ctx
|
37
|
+
end
|
38
|
+
|
39
|
+
# Executes a block with ctx as the current context. It restores
|
40
|
+
# the previous context upon exiting.
|
41
|
+
#
|
42
|
+
# @param [Context] ctx The context to be made active
|
43
|
+
# @yield [context] Yields context to the block
|
44
|
+
def with_current(ctx)
|
45
|
+
prev = ctx.attach
|
46
|
+
yield ctx
|
47
|
+
ensure
|
48
|
+
ctx.detach(prev)
|
49
|
+
end
|
50
|
+
|
51
|
+
# Execute a block in a new context with key set to value. Restores the
|
52
|
+
# previous context after the block executes.
|
53
|
+
|
54
|
+
# @param [String] key The lookup key
|
55
|
+
# @param [Object] value The object stored under key
|
56
|
+
# @param [Callable] Block to execute in a new context
|
57
|
+
# @yield [context, value] Yields the newly created context and value to
|
58
|
+
# the block
|
59
|
+
def with_value(key, value)
|
60
|
+
ctx = current.set_value(key, value)
|
61
|
+
prev = ctx.attach
|
62
|
+
yield ctx, value
|
63
|
+
ensure
|
64
|
+
ctx.detach(prev)
|
65
|
+
end
|
66
|
+
|
67
|
+
# Execute a block in a new context where its values are merged with the
|
68
|
+
# incoming values. Restores the previous context after the block executes.
|
69
|
+
|
70
|
+
# @param [String] key The lookup key
|
71
|
+
# @param [Hash] values Will be merged with values of the current context
|
72
|
+
# and returned in a new context
|
73
|
+
# @param [Callable] Block to execute in a new context
|
74
|
+
# @yield [context, values] Yields the newly created context and values
|
75
|
+
# to the block
|
76
|
+
def with_values(values)
|
77
|
+
ctx = current.set_values(values)
|
78
|
+
prev = ctx.attach
|
79
|
+
yield ctx, values
|
80
|
+
ensure
|
81
|
+
ctx.detach(prev)
|
82
|
+
end
|
83
|
+
|
84
|
+
# Returns the value associated with key in the current context
|
85
|
+
#
|
86
|
+
# @param [String] key The lookup key
|
87
|
+
def value(key)
|
88
|
+
current.value(key)
|
89
|
+
end
|
90
|
+
|
91
|
+
def clear
|
92
|
+
self.current = ROOT
|
93
|
+
end
|
11
94
|
|
12
|
-
|
13
|
-
|
95
|
+
def empty
|
96
|
+
new(nil, EMPTY_ENTRIES)
|
97
|
+
end
|
14
98
|
end
|
15
99
|
|
16
|
-
def
|
17
|
-
|
18
|
-
|
19
|
-
store[key] = value
|
20
|
-
yield value
|
21
|
-
ensure
|
22
|
-
store[key] = previous
|
100
|
+
def initialize(parent, entries)
|
101
|
+
@parent = parent
|
102
|
+
@entries = entries.freeze
|
23
103
|
end
|
24
104
|
|
25
|
-
|
105
|
+
# Returns the corresponding value (or nil) for key
|
106
|
+
#
|
107
|
+
# @param [Key] key The lookup key
|
108
|
+
# @return [Object]
|
109
|
+
def value(key)
|
110
|
+
@entries[key]
|
111
|
+
end
|
112
|
+
|
113
|
+
alias [] value
|
114
|
+
|
115
|
+
# Returns a new Context where entries contains the newly added key and value
|
116
|
+
#
|
117
|
+
# @param [Key] key The key to store this value under
|
118
|
+
# @param [Object] value Object to be stored under key
|
119
|
+
# @return [Context]
|
120
|
+
def set_value(key, value)
|
121
|
+
new_entries = @entries.dup
|
122
|
+
new_entries[key] = value
|
123
|
+
Context.new(self, new_entries)
|
124
|
+
end
|
125
|
+
|
126
|
+
# Returns a new Context with the current context's entries merged with the
|
127
|
+
# new entries
|
128
|
+
#
|
129
|
+
# @param [Hash] values The values to be merged with the current context's
|
130
|
+
# entries.
|
131
|
+
# @param [Object] value Object to be stored under key
|
132
|
+
# @return [Context]
|
133
|
+
def set_values(values) # rubocop:disable Naming/AccessorMethodName:
|
134
|
+
Context.new(self, @entries.merge(values))
|
135
|
+
end
|
26
136
|
|
27
|
-
|
28
|
-
|
137
|
+
# @api private
|
138
|
+
def attach
|
139
|
+
prev = self.class.current
|
140
|
+
self.class.current = self
|
141
|
+
prev
|
29
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
|
150
|
+
end
|
151
|
+
|
152
|
+
ROOT = empty.freeze
|
30
153
|
end
|
31
154
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2019 OpenTelemetry Authors
|
4
|
+
#
|
5
|
+
# SPDX-License-Identifier: Apache-2.0
|
6
|
+
|
7
|
+
module OpenTelemetry
|
8
|
+
class Context
|
9
|
+
# The Key class provides mechanisms to index and access values from a
|
10
|
+
# Context
|
11
|
+
class Key
|
12
|
+
attr_reader :name
|
13
|
+
|
14
|
+
# @api private
|
15
|
+
# Use Context.create_key to obtain a Key instance.
|
16
|
+
def initialize(name)
|
17
|
+
@name = name
|
18
|
+
end
|
19
|
+
|
20
|
+
# Returns the value indexed by this Key in the specified context
|
21
|
+
#
|
22
|
+
# @param [optional Context] context The Context to lookup the key from.
|
23
|
+
# Defaults to +Context.current+.
|
24
|
+
def get(context = Context.current)
|
25
|
+
context[self]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2019 OpenTelemetry Authors
|
4
|
+
#
|
5
|
+
# SPDX-License-Identifier: Apache-2.0
|
6
|
+
|
7
|
+
require 'opentelemetry/context/propagation/composite_propagator'
|
8
|
+
require 'opentelemetry/context/propagation/default_getter'
|
9
|
+
require 'opentelemetry/context/propagation/default_setter'
|
10
|
+
require 'opentelemetry/context/propagation/noop_extractor'
|
11
|
+
require 'opentelemetry/context/propagation/noop_injector'
|
12
|
+
require 'opentelemetry/context/propagation/propagation'
|
13
|
+
require 'opentelemetry/context/propagation/propagator'
|
14
|
+
|
15
|
+
module OpenTelemetry
|
16
|
+
class Context
|
17
|
+
# The propagation module contains APIs and utilities to interact with context
|
18
|
+
# and propagate across process boundaries.
|
19
|
+
module Propagation
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2020 OpenTelemetry Authors
|
4
|
+
#
|
5
|
+
# SPDX-License-Identifier: Apache-2.0
|
6
|
+
|
7
|
+
module OpenTelemetry
|
8
|
+
class Context
|
9
|
+
module Propagation
|
10
|
+
# A composite propagator composes a list of injectors and extractors into
|
11
|
+
# single interface exposing inject and extract methods. Injection and
|
12
|
+
# extraction will preserve the order of the injectors and extractors
|
13
|
+
# passed in during initialization.
|
14
|
+
class CompositePropagator
|
15
|
+
# Returns a Propagator that extracts using the provided extractors
|
16
|
+
# and injectors.
|
17
|
+
#
|
18
|
+
# @param [Array<#inject>] injectors
|
19
|
+
# @param [Array<#extract>] extractors
|
20
|
+
def initialize(injectors, extractors)
|
21
|
+
@injectors = injectors
|
22
|
+
@extractors = extractors
|
23
|
+
end
|
24
|
+
|
25
|
+
# Runs injectors in order and returns a carrier. If an injection fails
|
26
|
+
# a warning will be logged and remaining injectors will be executed.
|
27
|
+
# Always returns a valid carrier.
|
28
|
+
#
|
29
|
+
# @param [Object] carrier A carrier to inject context into
|
30
|
+
# context into
|
31
|
+
# @param [optional Context] context Context to be injected into carrier.
|
32
|
+
# Defaults to +Context.current+
|
33
|
+
# @param [optional Callable] setter An optional callable that takes a
|
34
|
+
# carrier, a key and a value and assigns the key-value pair in the
|
35
|
+
# carrier. If omitted the default setter will be used which expects
|
36
|
+
# the carrier to respond to [] and []=.
|
37
|
+
#
|
38
|
+
# @return [Object] carrier
|
39
|
+
def inject(carrier, context = Context.current, &setter)
|
40
|
+
@injectors.inject(carrier) do |memo, injector|
|
41
|
+
begin
|
42
|
+
injector.inject(memo, context, &setter)
|
43
|
+
rescue => e # rubocop:disable Style/RescueStandardError
|
44
|
+
OpenTelemetry.logger.warn "Error in CompositePropagator#inject #{e.message}"
|
45
|
+
carrier
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# Runs extractors in order and returns a Context updated with the
|
51
|
+
# results of each extraction. If an extraction fails, a warning will be
|
52
|
+
# logged and remaining extractors will continue to be executed. Always
|
53
|
+
# returns a valid context.
|
54
|
+
#
|
55
|
+
# @param [Object] carrier The carrier to extract context from
|
56
|
+
# @param [optional Context] context Context to be updated with the state
|
57
|
+
# extracted from the carrier. Defaults to +Context.current+
|
58
|
+
# @param [optional Callable] getter An optional callable that takes a carrier and a key and
|
59
|
+
# returns the value associated with the key. If omitted the default getter will be used
|
60
|
+
# which expects the carrier to respond to [] and []=.
|
61
|
+
#
|
62
|
+
# @return [Context] a new context updated with state extracted from the
|
63
|
+
# carrier
|
64
|
+
def extract(carrier, context = Context.current, &getter)
|
65
|
+
@extractors.inject(context) do |ctx, extractor|
|
66
|
+
begin
|
67
|
+
extractor.extract(carrier, ctx, &getter)
|
68
|
+
rescue => e # rubocop:disable Style/RescueStandardError
|
69
|
+
OpenTelemetry.logger.warn "Error in CompositePropagator#extract #{e.message}"
|
70
|
+
ctx
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|