opentelemetry-propagator-b3 0.11.0 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8cd24f1aed515a7b40801a96f12ea807e08c04cc328d42294643ab87c26edf02
4
- data.tar.gz: 64b6b02c902a973827cf624f3c4d8ce22f2d003daf5f8f7b6d4b40392148e1ed
3
+ metadata.gz: 13556a8ad4843308103d63e92356c269c87be42826bf0a026131b90eae0c0792
4
+ data.tar.gz: 9f7949588ae2a6b554b0bf3406acc05ce0c47008b06e83d3c0d04a9c23928ace
5
5
  SHA512:
6
- metadata.gz: 7c01eb89b7eda348229499c64abf7dcf4532c44198264b410ea14944ced4d143e914fc17945fad375de9ae6050d3e9dd00c4686a43566ba20a6bfb245a609508
7
- data.tar.gz: 030ca49d4acff6b1260278884ccf78b4d7b21657b3029b796f1da701a66f7eac3bb8ea94ddc6cb4aa0699ee04ffb6b00f379a40094ecda98aef9c553cac62cb3
6
+ metadata.gz: 8ff23eb11e5434e66be786ff15af0138f8d5c1a16cd7c852ce2f1a64262a2a7e561bd21201e72d3824b7a9ff6f691cd74fb41f6a349a5d50b9b8a9f03b072b3f
7
+ data.tar.gz: ba6f63d852685d0f651e0bb8512fea83ad357db2a5f925832e940acac773362f498eae5f39709a7aa1afe262e0279d5edf104f18df4846ba1d229c283de16990
data/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # Release History: opentelemetry-propagator-b3
2
2
 
3
+ ### v0.16.0 / 2021-03-17
4
+
5
+ * DOCS: Replace Gitter with GitHub Discussions
6
+
7
+ ### v0.15.0 / 2021-02-18
8
+
9
+ * (No significant changes)
10
+
11
+ ### v0.14.0 / 2021-02-03
12
+
13
+ * BREAKING CHANGE: Replace getter and setter callables and remove rack specific propagators
14
+
15
+ * ADDED: Replace getter and setter callables and remove rack specific propagators
16
+
17
+ ### v0.13.0 / 2021-01-29
18
+
19
+ * (No significant changes)
20
+
21
+ ### v0.12.0 / 2020-12-24
22
+
23
+ * (No significant changes)
24
+
3
25
  ### v0.11.0 / 2020-12-11
4
26
 
5
27
  * FIXED: Copyright comments to not reference year
data/README.md CHANGED
@@ -30,7 +30,7 @@ Or, if you use [bundler][bundler-home], include `opentelemetry-propagator-b3` in
30
30
 
31
31
  The `opentelemetry-propagator-b3` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`.
32
32
 
33
- 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].
33
+ The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us in [GitHub Discussions][discussions-url] 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].
34
34
 
35
35
  ## License
36
36
 
@@ -39,8 +39,8 @@ The `opentelemetry-propagator-b3` gem is distributed under the Apache 2.0 licens
39
39
  [opentelemetry-home]: https://opentelemetry.io
40
40
  [bundler-home]: https://bundler.io
41
41
  [repo-github]: https://github.com/open-telemetry/opentelemetry-ruby
42
- [license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/master/LICENSE
42
+ [license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE
43
43
  [ruby-sig]: https://github.com/open-telemetry/community#ruby-sig
44
44
  [community-meetings]: https://github.com/open-telemetry/community#community-meetings
45
- [ruby-gitter]: https://gitter.im/open-telemetry/opentelemetry-ruby
45
+ [discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions
46
46
  [b3-spec]: https://github.com/openzipkin/b3-propagation
@@ -22,19 +22,15 @@ module OpenTelemetry
22
22
  module Multi
23
23
  extend self
24
24
 
25
+ B3_TRACE_ID_KEY = 'X-B3-TraceId'
26
+ B3_SPAN_ID_KEY = 'X-B3-SpanId'
27
+ B3_SAMPLED_KEY = 'X-B3-Sampled'
28
+ B3_FLAGS_KEY = 'X-B3-Flags'
25
29
  TEXT_MAP_EXTRACTOR = TextMapExtractor.new
26
30
  TEXT_MAP_INJECTOR = TextMapInjector.new
27
- RACK_KEYS = {
28
- b3_trace_id_key: 'HTTP_X_B3_TRACEID',
29
- b3_span_id_key: 'HTTP_X_B3_SPANID',
30
- b3_sampled_key: 'HTTP_X_B3_SAMPLED',
31
- b3_flags_key: 'HTTP_X_B3_FLAGS'
32
- }.freeze
33
- RACK_EXTRACTOR = TextMapExtractor.new(**RACK_KEYS)
34
- RACK_INJECTOR = TextMapInjector.new(**RACK_KEYS)
35
31
 
36
- private_constant :TEXT_MAP_INJECTOR, :TEXT_MAP_EXTRACTOR, :RACK_INJECTOR,
37
- :RACK_EXTRACTOR, :RACK_KEYS
32
+ private_constant :B3_TRACE_ID_KEY, :B3_SPAN_ID_KEY, :B3_SAMPLED_KEY,
33
+ :B3_FLAGS_KEY, :TEXT_MAP_INJECTOR, :TEXT_MAP_EXTRACTOR
38
34
 
39
35
  # Returns an extractor that extracts context in the B3 multi header
40
36
  # format
@@ -47,20 +43,6 @@ module OpenTelemetry
47
43
  def text_map_extractor
48
44
  TEXT_MAP_EXTRACTOR
49
45
  end
50
-
51
- # Returns an extractor that extracts context in the B3 multi header
52
- # format with Rack normalized keys (upcased and prefixed with
53
- # HTTP_)
54
- def rack_injector
55
- RACK_INJECTOR
56
- end
57
-
58
- # Returns an injector that injects context in the B3 multi header
59
- # format with Rack normalized keys (upcased and prefixed with
60
- # HTTP_)
61
- def rack_extractor
62
- RACK_EXTRACTOR
63
- end
64
46
  end
65
47
  end
66
48
  end
@@ -19,8 +19,6 @@ module OpenTelemetry
19
19
  module Multi
20
20
  # Extracts context from carriers in the b3 single header format
21
21
  class TextMapExtractor
22
- include Context::Propagation::DefaultGetter
23
-
24
22
  B3_TRACE_ID_REGEX = /\A(?:[0-9a-f]{16}){1,2}\z/.freeze
25
23
  B3_SPAN_ID_REGEX = /\A[0-9a-f]{16}\z/.freeze
26
24
  SAMPLED_VALUES = %w[1 true].freeze
@@ -28,21 +26,14 @@ module OpenTelemetry
28
26
  private_constant :B3_TRACE_ID_REGEX, :B3_SPAN_ID_REGEX, :SAMPLED_VALUES, :DEBUG_FLAG
29
27
 
30
28
  # Returns a new TextMapExtractor that extracts b3 context using the
31
- # specified header keys
29
+ # specified getter
32
30
  #
33
- # @param [String] b3_trace_id_key The b3 trace id key used in the carrier
34
- # @param [String] b3_span_id_key The b3 span id key used in the carrier
35
- # @param [String] b3_sampled_key The b3 sampled key used in the carrier
36
- # @param [String] b3_flags_key The b3 flags key used in the carrier
31
+ # @param [optional Getter] default_getter The default getter used to read
32
+ # headers from a carrier during extract. Defaults to a
33
+ # {OpenTelemetry::Context:Propagation::TextMapGetter} instance.
37
34
  # @return [TextMapExtractor]
38
- def initialize(b3_trace_id_key: 'X-B3-TraceId',
39
- b3_span_id_key: 'X-B3-SpanId',
40
- b3_sampled_key: 'X-B3-Sampled',
41
- b3_flags_key: 'X-B3-Flags')
42
- @b3_trace_id_key = b3_trace_id_key
43
- @b3_span_id_key = b3_span_id_key
44
- @b3_sampled_key = b3_sampled_key
45
- @b3_flags_key = b3_flags_key
35
+ def initialize(default_getter = Context::Propagation.text_map_getter)
36
+ @default_getter = default_getter
46
37
  end
47
38
 
48
39
  # Extract b3 context from the supplied carrier and set the active span
@@ -51,24 +42,22 @@ module OpenTelemetry
51
42
  #
52
43
  # @param [Carrier] carrier The carrier to get the header from.
53
44
  # @param [Context] context The context to be updated with extracted context
54
- # @param [optional Callable] getter An optional callable that takes a carrier and a key and
55
- # returns the value associated with the key. If omitted the default getter will be used
56
- # which expects the carrier to respond to [] and []=.
57
- # @yield [Carrier, String] if an optional getter is provided, extract will yield the carrier
58
- # and the header key to the getter.
45
+ # @param [optional Getter] getter If the optional getter is provided, it
46
+ # will be used to read the header from the carrier, otherwise the default
47
+ # getter will be used.
59
48
  # @return [Context] Updated context with active span derived from the header, or the original
60
49
  # context if parsing fails.
61
- def extract(carrier, context, &getter)
62
- getter ||= default_getter
50
+ def extract(carrier, context, getter = nil)
51
+ getter ||= @default_getter
63
52
 
64
- trace_id_hex = getter.call(carrier, @b3_trace_id_key)
53
+ trace_id_hex = getter.get(carrier, B3_TRACE_ID_KEY)
65
54
  return context unless valid_trace_id?(trace_id_hex)
66
55
 
67
- span_id_hex = getter.call(carrier, @b3_span_id_key)
56
+ span_id_hex = getter.get(carrier, B3_SPAN_ID_KEY)
68
57
  return context unless valid_span_id?(span_id_hex)
69
58
 
70
- sampled = getter.call(carrier, @b3_sampled_key)
71
- flags = getter.call(carrier, @b3_flags_key)
59
+ sampled = getter.get(carrier, B3_SAMPLED_KEY)
60
+ flags = getter.get(carrier, B3_FLAGS_KEY)
72
61
 
73
62
  context = B3.context_with_debug(context) if flags == DEBUG_FLAG
74
63
 
@@ -12,49 +12,38 @@ module OpenTelemetry
12
12
  module Multi
13
13
  # Injects context into carriers using the b3 single header format
14
14
  class TextMapInjector
15
- include Context::Propagation::DefaultSetter
16
-
17
- # Returns a new TextMapInjector that extracts b3 context using the
18
- # specified header keys
15
+ # Returns a new TextMapInjector that injects b3 context using the
16
+ # specified setter
19
17
  #
20
- # @param [String] b3_trace_id_key The b3 trace id key used in the carrier
21
- # @param [String] b3_span_id_key The b3 span id key used in the carrier
22
- # @param [String] b3_sampled_key The b3 sampled key used in the carrier
23
- # @param [String] b3_flags_key The b3 flags key used in the carrier
18
+ # @param [optional Setter] default_setter The default setter used to
19
+ # write context into a carrier during inject. Defaults to a
20
+ # {OpenTelemetry::Context:Propagation::TextMapSetter} instance.
24
21
  # @return [TextMapInjector]
25
- def initialize(b3_trace_id_key: 'X-B3-TraceId',
26
- b3_span_id_key: 'X-B3-SpanId',
27
- b3_sampled_key: 'X-B3-Sampled',
28
- b3_flags_key: 'X-B3-Flags')
29
- @b3_trace_id_key = b3_trace_id_key
30
- @b3_span_id_key = b3_span_id_key
31
- @b3_sampled_key = b3_sampled_key
32
- @b3_flags_key = b3_flags_key
22
+ def initialize(default_setter = Context::Propagation.text_map_setter)
23
+ @default_setter = default_setter
33
24
  end
34
25
 
35
26
  # Set the span context on the supplied carrier.
36
27
  #
37
28
  # @param [Context] context The active Context.
38
- # @param [optional Callable] setter An optional callable that takes a carrier and a key and
39
- # a value and assigns the key-value pair in the carrier. If omitted the default setter
40
- # will be used which expects the carrier to respond to [] and []=.
41
- # @yield [Carrier, String, String] if an optional setter is provided, inject will yield
42
- # carrier, header key, header value to the setter.
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.
43
32
  # @return [Object] the carrier with context injected
44
- def inject(carrier, context, &setter)
33
+ def inject(carrier, context, setter = nil)
45
34
  span_context = Trace.current_span(context).context
46
35
  return unless span_context.valid?
47
36
 
48
- setter ||= default_setter
49
- setter.call(carrier, @b3_trace_id_key, span_context.hex_trace_id)
50
- setter.call(carrier, @b3_span_id_key, span_context.hex_span_id)
37
+ setter ||= @default_setter
38
+ setter.set(carrier, B3_TRACE_ID_KEY, span_context.hex_trace_id)
39
+ setter.set(carrier, B3_SPAN_ID_KEY, span_context.hex_span_id)
51
40
 
52
41
  if B3.debug?(context)
53
- setter.call(carrier, @b3_flags_key, '1')
42
+ setter.set(carrier, B3_FLAGS_KEY, '1')
54
43
  elsif span_context.trace_flags.sampled?
55
- setter.call(carrier, @b3_sampled_key, '1')
44
+ setter.set(carrier, B3_SAMPLED_KEY, '1')
56
45
  else
57
- setter.call(carrier, @b3_sampled_key, '0')
46
+ setter.set(carrier, B3_SAMPLED_KEY, '0')
58
47
  end
59
48
 
60
49
  carrier
@@ -22,17 +22,11 @@ module OpenTelemetry
22
22
  module Single
23
23
  extend self
24
24
 
25
+ B3_CONTEXT_KEY = 'b3'
25
26
  TEXT_MAP_EXTRACTOR = TextMapExtractor.new
26
27
  TEXT_MAP_INJECTOR = TextMapInjector.new
27
- RACK_EXTRACTOR = TextMapExtractor.new(
28
- b3_key: 'HTTP_B3'
29
- )
30
- RACK_INJECTOR = TextMapInjector.new(
31
- b3_key: 'HTTP_B3'
32
- )
33
28
 
34
- private_constant :TEXT_MAP_INJECTOR, :TEXT_MAP_EXTRACTOR, :RACK_INJECTOR,
35
- :RACK_EXTRACTOR
29
+ private_constant :B3_CONTEXT_KEY, :TEXT_MAP_INJECTOR, :TEXT_MAP_EXTRACTOR
36
30
 
37
31
  # Returns an extractor that extracts context in the B3 single header
38
32
  # format
@@ -45,20 +39,6 @@ module OpenTelemetry
45
39
  def text_map_extractor
46
40
  TEXT_MAP_EXTRACTOR
47
41
  end
48
-
49
- # Returns an extractor that extracts context in the B3 single header
50
- # format with Rack normalized keys (upcased and prefixed with
51
- # HTTP_)
52
- def rack_injector
53
- RACK_INJECTOR
54
- end
55
-
56
- # Returns an injector that injects context in the B3 single header
57
- # format with Rack normalized keys (upcased and prefixed with
58
- # HTTP_)
59
- def rack_extractor
60
- RACK_EXTRACTOR
61
- end
62
42
  end
63
43
  end
64
44
  end
@@ -19,18 +19,18 @@ module OpenTelemetry
19
19
  module Single
20
20
  # Extracts context from carriers in the b3 single header format
21
21
  class TextMapExtractor
22
- include Context::Propagation::DefaultGetter
23
-
24
22
  B3_CONTEXT_REGEX = /\A(?<trace_id>(?:[0-9a-f]{16}){1,2})-(?<span_id>[0-9a-f]{16})(?:-(?<sampling_state>[01d](?![0-9a-f])))?(?:-(?<parent_span_id>[0-9a-f]{16}))?\z/.freeze
25
23
  SAMPLED_VALUES = %w[1 d].freeze
26
24
 
27
25
  # Returns a new TextMapExtractor that extracts b3 context using the
28
- # specified header keys
26
+ # specified getter
29
27
  #
30
- # @param [String] b3_key The b3 header key used in the carrier
28
+ # @param [optional Getter] default_getter The default getter used to read
29
+ # headers from a carrier during extract. Defaults to a
30
+ # {OpenTelemetry::Context:Propagation::TextMapGetter} instance.
31
31
  # @return [TextMapExtractor]
32
- def initialize(b3_key: 'b3')
33
- @b3_key = b3_key
32
+ def initialize(default_getter = Context::Propagation.text_map_getter)
33
+ @default_getter = default_getter
34
34
  end
35
35
 
36
36
  # Extract b3 context from the supplied carrier and set the active span
@@ -39,16 +39,14 @@ module OpenTelemetry
39
39
  #
40
40
  # @param [Carrier] carrier The carrier to get the header from.
41
41
  # @param [Context] context The context to be updated with extracted context
42
- # @param [optional Callable] getter An optional callable that takes a carrier and a key and
43
- # returns the value associated with the key. If omitted the default getter will be used
44
- # which expects the carrier to respond to [] and []=.
45
- # @yield [Carrier, String] if an optional getter is provided, extract will yield the carrier
46
- # and the header key to the getter.
42
+ # @param [optional Getter] getter If the optional getter is provided, it
43
+ # will be used to read the header from the carrier, otherwise the default
44
+ # getter will be used.
47
45
  # @return [Context] Updated context with active span derived from the header, or the original
48
46
  # context if parsing fails.
49
- def extract(carrier, context, &getter)
50
- getter ||= default_getter
51
- header = getter.call(carrier, @b3_key)
47
+ def extract(carrier, context, getter = nil)
48
+ getter ||= @default_getter
49
+ header = getter.get(carrier, B3_CONTEXT_KEY)
52
50
  return context unless (match = header.match(B3_CONTEXT_REGEX))
53
51
 
54
52
  span_context = Trace::SpanContext.new(
@@ -12,27 +12,25 @@ module OpenTelemetry
12
12
  module Single
13
13
  # Injects context into carriers using the b3 single header format
14
14
  class TextMapInjector
15
- include Context::Propagation::DefaultSetter
16
-
17
- # Returns a new TextMapInjector that extracts b3 context using the
18
- # specified header keys
15
+ # Returns a new TextMapInjector that injects b3 context using the
16
+ # specified setter
19
17
  #
20
- # @param [String] b3_key The b3 header key used in the carrier
18
+ # @param [optional Setter] default_setter The default setter used to
19
+ # write context into a carrier during inject. Defaults to a
20
+ # {OpenTelemetry::Context:Propagation::TextMapSetter} instance.
21
21
  # @return [TextMapInjector]
22
- def initialize(b3_key: 'b3')
23
- @b3_key = b3_key
22
+ def initialize(default_setter = Context::Propagation.text_map_setter)
23
+ @default_setter = default_setter
24
24
  end
25
25
 
26
26
  # Set the span context on the supplied carrier.
27
27
  #
28
28
  # @param [Context] context The active Context.
29
- # @param [optional Callable] setter An optional callable that takes a carrier and a key and
30
- # a value and assigns the key-value pair in the carrier. If omitted the default setter
31
- # will be used which expects the carrier to respond to [] and []=.
32
- # @yield [Carrier, String, String] if an optional setter is provided, inject will yield
33
- # carrier, header key, header value to the setter.
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.
34
32
  # @return [Object] the carrier with context injected
35
- def inject(carrier, context, &setter)
33
+ def inject(carrier, context, setter = nil)
36
34
  span_context = Trace.current_span(context).context
37
35
  return unless span_context.valid?
38
36
 
@@ -46,8 +44,8 @@ module OpenTelemetry
46
44
 
47
45
  b3_value = "#{span_context.hex_trace_id}-#{span_context.hex_span_id}-#{sampling_state}"
48
46
 
49
- setter ||= default_setter
50
- setter.call(carrier, @b3_key, b3_value)
47
+ setter ||= @default_setter
48
+ setter.set(carrier, B3_CONTEXT_KEY, b3_value)
51
49
  carrier
52
50
  end
53
51
  end
@@ -7,7 +7,7 @@
7
7
  module OpenTelemetry
8
8
  module Propagator
9
9
  module B3
10
- VERSION = '0.11.0'
10
+ VERSION = '0.16.0'
11
11
  end
12
12
  end
13
13
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opentelemetry-propagator-b3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenTelemetry Authors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-11 00:00:00.000000000 Z
11
+ date: 2021-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opentelemetry-api
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.11.0
19
+ version: 0.16.0
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.11.0
26
+ version: 0.16.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -146,10 +146,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby
146
146
  licenses:
147
147
  - Apache-2.0
148
148
  metadata:
149
- changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-propagator-b3/v0.11.0/file.CHANGELOG.html
150
- source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/master/propagator/b3
149
+ changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-propagator-b3/v0.16.0/file.CHANGELOG.html
150
+ source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/propagator/b3
151
151
  bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby/issues
152
- documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-propagator-b3/v0.11.0
152
+ documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-propagator-b3/v0.16.0
153
153
  post_install_message:
154
154
  rdoc_options: []
155
155
  require_paths: