opentelemetry-api 0.10.0 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +27 -0
- data/LICENSE +1 -1
- data/README.md +2 -2
- data/lib/opentelemetry-api.rb +1 -1
- data/lib/opentelemetry.rb +22 -4
- data/lib/opentelemetry/baggage.rb +1 -1
- data/lib/opentelemetry/baggage/builder.rb +1 -1
- data/lib/opentelemetry/baggage/manager.rb +1 -1
- data/lib/opentelemetry/baggage/propagation.rb +3 -23
- data/lib/opentelemetry/baggage/propagation/context_keys.rb +1 -1
- data/lib/opentelemetry/baggage/propagation/text_map_extractor.rb +13 -16
- data/lib/opentelemetry/baggage/propagation/text_map_injector.rb +13 -16
- data/lib/opentelemetry/context.rb +1 -1
- data/lib/opentelemetry/context/key.rb +1 -1
- data/lib/opentelemetry/context/propagation.rb +29 -4
- data/lib/opentelemetry/context/propagation/composite_propagator.rb +11 -12
- data/lib/opentelemetry/context/propagation/noop_extractor.rb +2 -2
- data/lib/opentelemetry/context/propagation/noop_injector.rb +1 -1
- data/lib/opentelemetry/context/propagation/propagator.rb +11 -11
- data/lib/opentelemetry/context/propagation/rack_env_getter.rb +46 -0
- data/lib/opentelemetry/context/propagation/text_map_getter.rb +27 -0
- data/lib/opentelemetry/context/propagation/text_map_setter.rb +21 -0
- data/lib/opentelemetry/error.rb +1 -1
- data/lib/opentelemetry/instrumentation.rb +1 -1
- data/lib/opentelemetry/instrumentation/base.rb +1 -1
- data/lib/opentelemetry/instrumentation/registry.rb +2 -3
- data/lib/opentelemetry/metrics.rb +1 -1
- data/lib/opentelemetry/metrics/handles.rb +1 -1
- data/lib/opentelemetry/metrics/instruments.rb +1 -1
- data/lib/opentelemetry/metrics/meter.rb +1 -1
- data/lib/opentelemetry/metrics/meter_provider.rb +1 -1
- data/lib/opentelemetry/trace.rb +15 -4
- data/lib/opentelemetry/trace/link.rb +1 -1
- data/lib/opentelemetry/trace/propagation.rb +1 -1
- data/lib/opentelemetry/trace/propagation/trace_context.rb +5 -24
- data/lib/opentelemetry/trace/propagation/trace_context/text_map_extractor.rb +14 -21
- data/lib/opentelemetry/trace/propagation/trace_context/text_map_injector.rb +14 -19
- data/lib/opentelemetry/trace/propagation/trace_context/trace_parent.rb +1 -1
- data/lib/opentelemetry/trace/span.rb +6 -2
- data/lib/opentelemetry/trace/span_context.rb +3 -3
- data/lib/opentelemetry/trace/span_kind.rb +1 -1
- data/lib/opentelemetry/trace/status.rb +1 -1
- data/lib/opentelemetry/trace/trace_flags.rb +1 -1
- data/lib/opentelemetry/trace/tracer.rb +1 -1
- data/lib/opentelemetry/trace/tracer_provider.rb +1 -1
- data/lib/opentelemetry/trace/tracestate.rb +158 -0
- data/lib/opentelemetry/trace/util/http_to_status.rb +1 -1
- data/lib/opentelemetry/version.rb +2 -2
- metadata +9 -8
- 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/propagation.rb +0 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23c4a8602afe2513fff72ec29784b696ae41eccee8c3b25eb4cf48081856b22b
|
4
|
+
data.tar.gz: 17507ad2d0dbb697e6f1bb8cbf133d0baa01234d7383d9bb726b0d5fb11c4cb3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c37bb2d8a469bda44a121bfca1218380553cbc66d24e8001df4c2e67d93f9b474335962095b77a28e6de3c53f34af98ea18b12a3335cdd45d0b04d50510b2be
|
7
|
+
data.tar.gz: 3980934cdfdb34e96eb8215a9ebb26eb0b3d096be3e545837ee9d6595ff5e114ea680e692ccc7d0af2d89d8a4550e180671e4d92c5266b6a445c45fc991e0602
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,32 @@
|
|
1
1
|
# Release History: opentelemetry-api
|
2
2
|
|
3
|
+
### v0.14.0 / 2021-02-03
|
4
|
+
|
5
|
+
* BREAKING CHANGE: Replace getter and setter callables and remove rack specific propagators
|
6
|
+
|
7
|
+
* ADDED: Replace getter and setter callables and remove rack specific propagators
|
8
|
+
|
9
|
+
### v0.13.0 / 2021-01-29
|
10
|
+
|
11
|
+
* ADDED: Add optional attributes to record_exception
|
12
|
+
* FIXED: Small test fixes.
|
13
|
+
|
14
|
+
### v0.12.1 / 2021-01-13
|
15
|
+
|
16
|
+
* FIXED: Eliminate warning about Random::DEFAULT on Ruby 3.0
|
17
|
+
|
18
|
+
### v0.12.0 / 2020-12-24
|
19
|
+
|
20
|
+
* ADDED: Structured error handling
|
21
|
+
|
22
|
+
### v0.11.0 / 2020-12-11
|
23
|
+
|
24
|
+
* BREAKING CHANGE: Implement tracestate
|
25
|
+
|
26
|
+
* ADDED: Implement tracestate
|
27
|
+
* FIXED: Missing white space from install messages
|
28
|
+
* FIXED: Copyright comments to not reference year
|
29
|
+
|
3
30
|
### v0.10.0 / 2020-12-03
|
4
31
|
|
5
32
|
* (No significant changes)
|
data/LICENSE
CHANGED
@@ -186,7 +186,7 @@
|
|
186
186
|
same "printed page" as the copyright notice for easier
|
187
187
|
identification within third-party archives.
|
188
188
|
|
189
|
-
Copyright
|
189
|
+
Copyright The OpenTelemetry Authors
|
190
190
|
|
191
191
|
Licensed under the Apache License, Version 2.0 (the "License");
|
192
192
|
you may not use this file except in compliance with the License.
|
data/README.md
CHANGED
@@ -59,8 +59,8 @@ The `opentelemetry-api` gem is distributed under the Apache 2.0 license. See [LI
|
|
59
59
|
[opentelemetry-home]: https://opentelemetry.io
|
60
60
|
[bundler-home]: https://bundler.io
|
61
61
|
[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby
|
62
|
-
[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/
|
63
|
-
[examples-github]: https://github.com/open-telemetry/opentelemetry-ruby/tree/
|
62
|
+
[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE
|
63
|
+
[examples-github]: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/examples
|
64
64
|
[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig
|
65
65
|
[community-meetings]: https://github.com/open-telemetry/community#community-meetings
|
66
66
|
[ruby-gitter]: https://gitter.im/open-telemetry/opentelemetry-ruby
|
data/lib/opentelemetry-api.rb
CHANGED
data/lib/opentelemetry.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright
|
3
|
+
# Copyright The OpenTelemetry Authors
|
4
4
|
#
|
5
5
|
# SPDX-License-Identifier: Apache-2.0
|
6
6
|
|
@@ -22,13 +22,28 @@ require 'opentelemetry/version'
|
|
22
22
|
module OpenTelemetry
|
23
23
|
extend self
|
24
24
|
|
25
|
-
attr_writer :tracer_provider, :meter_provider, :
|
25
|
+
attr_writer :tracer_provider, :meter_provider, :propagation, :baggage,
|
26
|
+
:logger, :error_handler
|
26
27
|
|
27
28
|
# @return [Object, Logger] configured Logger or a default STDOUT Logger.
|
28
29
|
def logger
|
29
30
|
@logger ||= Logger.new(STDOUT, level: ENV['OTEL_LOG_LEVEL'] || Logger::INFO)
|
30
31
|
end
|
31
32
|
|
33
|
+
# @return [Callable] configured error handler or a default that logs the
|
34
|
+
# exception and message at ERROR level.
|
35
|
+
def error_handler
|
36
|
+
@error_handler ||= ->(exception: nil, message: nil) { logger.error("OpenTelemetry error: #{[message, exception&.message].compact.join(' - ')}") }
|
37
|
+
end
|
38
|
+
|
39
|
+
# Handles an error by calling the configured error_handler.
|
40
|
+
#
|
41
|
+
# @param [optional Exception] exception The exception to be handled
|
42
|
+
# @param [optional String] message An error message.
|
43
|
+
def handle_error(exception: nil, message: nil)
|
44
|
+
error_handler.call(exception: exception, message: message)
|
45
|
+
end
|
46
|
+
|
32
47
|
# @return [Object, Trace::TracerProvider] registered tracer provider or a
|
33
48
|
# default no-op implementation of the tracer provider.
|
34
49
|
def tracer_provider
|
@@ -54,8 +69,11 @@ module OpenTelemetry
|
|
54
69
|
@baggage ||= Baggage::Manager.new
|
55
70
|
end
|
56
71
|
|
57
|
-
# @return [Context::Propagation::
|
72
|
+
# @return [Context::Propagation::Propagator] a propagator instance
|
58
73
|
def propagation
|
59
|
-
@propagation ||= Context::Propagation::
|
74
|
+
@propagation ||= Context::Propagation::Propagator.new(
|
75
|
+
Context::Propagation::NoopInjector.new,
|
76
|
+
Context::Propagation::NoopExtractor.new
|
77
|
+
)
|
60
78
|
end
|
61
79
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright
|
3
|
+
# Copyright The OpenTelemetry Authors
|
4
4
|
#
|
5
5
|
# SPDX-License-Identifier: Apache-2.0
|
6
6
|
|
@@ -15,17 +15,11 @@ module OpenTelemetry
|
|
15
15
|
module Propagation
|
16
16
|
extend self
|
17
17
|
|
18
|
+
BAGGAGE_KEY = 'baggage'
|
18
19
|
TEXT_MAP_EXTRACTOR = TextMapExtractor.new
|
19
20
|
TEXT_MAP_INJECTOR = TextMapInjector.new
|
20
|
-
RACK_EXTRACTOR = TextMapExtractor.new(
|
21
|
-
baggage_key: 'HTTP_BAGGAGE'
|
22
|
-
)
|
23
|
-
RACK_INJECTOR = TextMapInjector.new(
|
24
|
-
baggage_key: 'HTTP_BAGGAGE'
|
25
|
-
)
|
26
21
|
|
27
|
-
private_constant :
|
28
|
-
:RACK_EXTRACTOR
|
22
|
+
private_constant :BAGGAGE_KEY, :TEXT_MAP_INJECTOR, :TEXT_MAP_EXTRACTOR
|
29
23
|
|
30
24
|
# Returns an extractor that extracts context using the W3C Baggage
|
31
25
|
# format
|
@@ -38,20 +32,6 @@ module OpenTelemetry
|
|
38
32
|
def text_map_extractor
|
39
33
|
TEXT_MAP_EXTRACTOR
|
40
34
|
end
|
41
|
-
|
42
|
-
# Returns an extractor that extracts context using the W3C Baggage
|
43
|
-
# format with Rack normalized keys (upcased and prefixed with
|
44
|
-
# HTTP_)
|
45
|
-
def rack_injector
|
46
|
-
RACK_INJECTOR
|
47
|
-
end
|
48
|
-
|
49
|
-
# Returns an injector that injects context using the W3C Baggage
|
50
|
-
# format with Rack normalized keys (upcased and prefixed with
|
51
|
-
# HTTP_)
|
52
|
-
def rack_extractor
|
53
|
-
RACK_EXTRACTOR
|
54
|
-
end
|
55
35
|
end
|
56
36
|
end
|
57
37
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright
|
3
|
+
# Copyright The OpenTelemetry Authors
|
4
4
|
#
|
5
5
|
# SPDX-License-Identifier: Apache-2.0
|
6
6
|
|
@@ -11,16 +11,15 @@ module OpenTelemetry
|
|
11
11
|
module Propagation
|
12
12
|
# Extracts baggage from carriers in the W3C Baggage format
|
13
13
|
class TextMapExtractor
|
14
|
-
include Context::Propagation::DefaultGetter
|
15
|
-
|
16
14
|
# Returns a new TextMapExtractor that extracts context using the specified
|
17
|
-
#
|
15
|
+
# getter
|
18
16
|
#
|
19
|
-
# @param [
|
20
|
-
#
|
17
|
+
# @param [optional Getter] default_getter The default getter used to read
|
18
|
+
# headers from a carrier during extract. Defaults to a
|
19
|
+
# {OpenTelemetry::Context::Propagation::TextMapGetter} instance.
|
21
20
|
# @return [TextMapExtractor]
|
22
|
-
def initialize(
|
23
|
-
@
|
21
|
+
def initialize(default_getter = Context::Propagation.text_map_getter)
|
22
|
+
@default_getter = default_getter
|
24
23
|
end
|
25
24
|
|
26
25
|
# Extract remote baggage from the supplied carrier.
|
@@ -28,16 +27,14 @@ module OpenTelemetry
|
|
28
27
|
#
|
29
28
|
# @param [Carrier] carrier The carrier to get the header from
|
30
29
|
# @param [Context] context The context to be updated with extracted baggage
|
31
|
-
# @param [optional
|
32
|
-
#
|
33
|
-
#
|
34
|
-
# @yield [Carrier, String] if an optional getter is provided, extract will yield the carrier
|
35
|
-
# and the header key to the getter.
|
30
|
+
# @param [optional Getter] getter If the optional getter is provided, it
|
31
|
+
# will be used to read the header from the carrier, otherwise the default
|
32
|
+
# getter will be used.
|
36
33
|
# @return [Context] context updated with extracted baggage, or the original context
|
37
34
|
# if extraction fails
|
38
|
-
def extract(carrier, context,
|
39
|
-
getter ||= default_getter
|
40
|
-
header = getter.
|
35
|
+
def extract(carrier, context, getter = nil)
|
36
|
+
getter ||= @default_getter
|
37
|
+
header = getter.get(carrier, BAGGAGE_KEY)
|
41
38
|
|
42
39
|
entries = header.gsub(/\s/, '').split(',')
|
43
40
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright
|
3
|
+
# Copyright The OpenTelemetry Authors
|
4
4
|
#
|
5
5
|
# SPDX-License-Identifier: Apache-2.0
|
6
6
|
|
@@ -11,33 +11,30 @@ module OpenTelemetry
|
|
11
11
|
module Propagation
|
12
12
|
# Injects baggage using the W3C Baggage format
|
13
13
|
class TextMapInjector
|
14
|
-
include Context::Propagation::DefaultSetter
|
15
|
-
|
16
14
|
# Returns a new TextMapInjector that injects context using the specified
|
17
|
-
#
|
15
|
+
# setter
|
18
16
|
#
|
19
|
-
# @param [
|
20
|
-
#
|
17
|
+
# @param [optional Setter] default_setter The default setter used to
|
18
|
+
# write context into a carrier during inject. Defaults to a
|
19
|
+
# {OpenTelemetry::Context::Propagation::TextMapSetter} instance.
|
21
20
|
# @return [TextMapInjector]
|
22
|
-
def initialize(
|
23
|
-
@
|
21
|
+
def initialize(default_setter = Context::Propagation.text_map_setter)
|
22
|
+
@default_setter = default_setter
|
24
23
|
end
|
25
24
|
|
26
25
|
# Inject in-process baggage into the supplied carrier.
|
27
26
|
#
|
28
27
|
# @param [Carrier] carrier The carrier to inject baggage into
|
29
28
|
# @param [Context] context The context to read baggage from
|
30
|
-
# @param [optional
|
31
|
-
#
|
32
|
-
#
|
33
|
-
# @yield [Carrier, String] if an optional getter is provided, inject will yield the carrier
|
34
|
-
# and the header key to the getter.
|
29
|
+
# @param [optional Setter] setter If the optional setter is provided, it
|
30
|
+
# will be used to write context into the carrier, otherwise the default
|
31
|
+
# setter will be used.
|
35
32
|
# @return [Object] carrier with injected baggage
|
36
|
-
def inject(carrier, context,
|
33
|
+
def inject(carrier, context, setter = nil)
|
37
34
|
return carrier unless (baggage = context[ContextKeys.baggage_key]) && !baggage.empty?
|
38
35
|
|
39
|
-
setter ||= default_setter
|
40
|
-
setter.
|
36
|
+
setter ||= @default_setter
|
37
|
+
setter.set(carrier, BAGGAGE_KEY, encode(baggage))
|
41
38
|
|
42
39
|
carrier
|
43
40
|
end
|
@@ -1,22 +1,47 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright
|
3
|
+
# Copyright The OpenTelemetry Authors
|
4
4
|
#
|
5
5
|
# SPDX-License-Identifier: Apache-2.0
|
6
6
|
|
7
7
|
require 'opentelemetry/context/propagation/composite_propagator'
|
8
|
-
require 'opentelemetry/context/propagation/default_getter'
|
9
|
-
require 'opentelemetry/context/propagation/default_setter'
|
10
8
|
require 'opentelemetry/context/propagation/noop_extractor'
|
11
9
|
require 'opentelemetry/context/propagation/noop_injector'
|
12
|
-
require 'opentelemetry/context/propagation/propagation'
|
13
10
|
require 'opentelemetry/context/propagation/propagator'
|
11
|
+
require 'opentelemetry/context/propagation/text_map_getter'
|
12
|
+
require 'opentelemetry/context/propagation/text_map_setter'
|
13
|
+
require 'opentelemetry/context/propagation/rack_env_getter'
|
14
14
|
|
15
15
|
module OpenTelemetry
|
16
16
|
class Context
|
17
17
|
# The propagation module contains APIs and utilities to interact with context
|
18
18
|
# and propagate across process boundaries.
|
19
19
|
module Propagation
|
20
|
+
extend self
|
21
|
+
|
22
|
+
TEXT_MAP_GETTER = TextMapGetter.new
|
23
|
+
TEXT_MAP_SETTER = TextMapSetter.new
|
24
|
+
RACK_ENV_GETTER = RackEnvGetter.new
|
25
|
+
|
26
|
+
private_constant :TEXT_MAP_GETTER, :TEXT_MAP_SETTER, :RACK_ENV_GETTER
|
27
|
+
|
28
|
+
# Returns a {TextMapGetter} instance suitable for reading values from a
|
29
|
+
# hash-like carrier
|
30
|
+
def text_map_getter
|
31
|
+
TEXT_MAP_GETTER
|
32
|
+
end
|
33
|
+
|
34
|
+
# Returns a {TextMapSetter} instance suitable for writing values into a
|
35
|
+
# hash-like carrier
|
36
|
+
def text_map_setter
|
37
|
+
TEXT_MAP_SETTER
|
38
|
+
end
|
39
|
+
|
40
|
+
# Returns a {RackEnvGetter} instance suitable for reading values from a
|
41
|
+
# Rack environment.
|
42
|
+
def rack_env_getter
|
43
|
+
RACK_ENV_GETTER
|
44
|
+
end
|
20
45
|
end
|
21
46
|
end
|
22
47
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright
|
3
|
+
# Copyright The OpenTelemetry Authors
|
4
4
|
#
|
5
5
|
# SPDX-License-Identifier: Apache-2.0
|
6
6
|
|
@@ -30,15 +30,14 @@ module OpenTelemetry
|
|
30
30
|
# context into
|
31
31
|
# @param [optional Context] context Context to be injected into carrier.
|
32
32
|
# Defaults to +Context.current+
|
33
|
-
# @param [optional
|
34
|
-
#
|
35
|
-
#
|
36
|
-
# the carrier to respond to [] and []=.
|
33
|
+
# @param [optional Setter] setter If the optional setter is provided, it
|
34
|
+
# will be used to write context into the carrier, otherwise the default
|
35
|
+
# setter will be used.
|
37
36
|
#
|
38
37
|
# @return [Object] carrier
|
39
|
-
def inject(carrier, context
|
38
|
+
def inject(carrier, context: Context.current, setter: Context::Propagation.text_map_setter)
|
40
39
|
@injectors.inject(carrier) do |memo, injector|
|
41
|
-
injector.inject(memo, context,
|
40
|
+
injector.inject(memo, context, setter)
|
42
41
|
rescue => e # rubocop:disable Style/RescueStandardError
|
43
42
|
OpenTelemetry.logger.warn "Error in CompositePropagator#inject #{e.message}"
|
44
43
|
carrier
|
@@ -53,15 +52,15 @@ module OpenTelemetry
|
|
53
52
|
# @param [Object] carrier The carrier to extract context from
|
54
53
|
# @param [optional Context] context Context to be updated with the state
|
55
54
|
# extracted from the carrier. Defaults to +Context.current+
|
56
|
-
# @param [optional
|
57
|
-
#
|
58
|
-
#
|
55
|
+
# @param [optional Getter] getter If the optional getter is provided, it
|
56
|
+
# will be used to read the header from the carrier, otherwise the default
|
57
|
+
# getter will be used.
|
59
58
|
#
|
60
59
|
# @return [Context] a new context updated with state extracted from the
|
61
60
|
# carrier
|
62
|
-
def extract(carrier, context
|
61
|
+
def extract(carrier, context: Context.current, getter: Context::Propagation.text_map_getter)
|
63
62
|
@extractors.inject(context) do |ctx, extractor|
|
64
|
-
extractor.extract(carrier, ctx,
|
63
|
+
extractor.extract(carrier, ctx, getter)
|
65
64
|
rescue => e # rubocop:disable Style/RescueStandardError
|
66
65
|
OpenTelemetry.logger.warn "Error in CompositePropagator#extract #{e.message}"
|
67
66
|
ctx
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright
|
3
|
+
# Copyright The OpenTelemetry Authors
|
4
4
|
#
|
5
5
|
# SPDX-License-Identifier: Apache-2.0
|
6
6
|
|
@@ -17,7 +17,7 @@ module OpenTelemetry
|
|
17
17
|
# @param [optional Callable] getter An optional callable that takes a carrier and a key and
|
18
18
|
# and returns the value associated with the key
|
19
19
|
# @return [Context]
|
20
|
-
def extract(carrier, context,
|
20
|
+
def extract(carrier, context, getter = nil)
|
21
21
|
context
|
22
22
|
end
|
23
23
|
end
|