opentelemetry-api 0.2.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +9 -0
  3. data/CHANGELOG.md +13 -0
  4. data/LICENSE +1 -1
  5. data/OVERVIEW.md +66 -0
  6. data/lib/{opentelemetry/distributed_context/manager.rb → opentelemetry-api.rb} +1 -6
  7. data/lib/opentelemetry.rb +37 -19
  8. data/lib/opentelemetry/baggage.rb +16 -0
  9. data/lib/opentelemetry/baggage/builder.rb +18 -0
  10. data/lib/opentelemetry/baggage/manager.rb +41 -0
  11. data/lib/opentelemetry/baggage/propagation.rb +57 -0
  12. data/lib/opentelemetry/baggage/propagation/context_keys.rb +27 -0
  13. data/lib/opentelemetry/baggage/propagation/text_map_extractor.rb +60 -0
  14. data/lib/opentelemetry/baggage/propagation/text_map_injector.rb +55 -0
  15. data/lib/opentelemetry/context.rb +138 -15
  16. data/lib/opentelemetry/context/key.rb +29 -0
  17. data/lib/opentelemetry/context/propagation.rb +22 -0
  18. data/lib/opentelemetry/context/propagation/composite_propagator.rb +73 -0
  19. data/lib/opentelemetry/context/propagation/default_getter.rb +26 -0
  20. data/lib/opentelemetry/context/propagation/default_setter.rb +26 -0
  21. data/lib/opentelemetry/context/propagation/noop_extractor.rb +26 -0
  22. data/lib/opentelemetry/context/propagation/noop_injector.rb +26 -0
  23. data/lib/opentelemetry/context/propagation/propagation.rb +27 -0
  24. data/lib/opentelemetry/context/propagation/propagator.rb +64 -0
  25. data/lib/opentelemetry/instrumentation.rb +15 -0
  26. data/lib/opentelemetry/instrumentation/base.rb +245 -0
  27. data/lib/opentelemetry/instrumentation/registry.rb +87 -0
  28. data/lib/opentelemetry/metrics.rb +1 -1
  29. data/lib/opentelemetry/metrics/handles.rb +5 -15
  30. data/lib/opentelemetry/metrics/instruments.rb +18 -69
  31. data/lib/opentelemetry/metrics/meter.rb +2 -39
  32. data/lib/opentelemetry/metrics/{meter_factory.rb → meter_provider.rb} +2 -2
  33. data/lib/opentelemetry/trace.rb +14 -17
  34. data/lib/opentelemetry/trace/link.rb +4 -3
  35. data/lib/opentelemetry/trace/propagation.rb +17 -0
  36. data/lib/opentelemetry/trace/propagation/context_keys.rb +35 -0
  37. data/lib/opentelemetry/trace/propagation/trace_context.rb +59 -0
  38. data/lib/opentelemetry/trace/propagation/trace_context/text_map_extractor.rb +58 -0
  39. data/lib/opentelemetry/trace/propagation/trace_context/text_map_injector.rb +55 -0
  40. data/lib/opentelemetry/trace/propagation/trace_context/trace_parent.rb +130 -0
  41. data/lib/opentelemetry/trace/span.rb +20 -20
  42. data/lib/opentelemetry/trace/span_context.rb +25 -1
  43. data/lib/opentelemetry/trace/status.rb +7 -2
  44. data/lib/opentelemetry/trace/tracer.rb +47 -13
  45. data/lib/opentelemetry/trace/tracer_provider.rb +22 -0
  46. data/lib/opentelemetry/trace/util/http_to_status.rb +47 -0
  47. data/lib/opentelemetry/version.rb +1 -1
  48. metadata +35 -17
  49. data/lib/opentelemetry/distributed_context.rb +0 -19
  50. data/lib/opentelemetry/distributed_context/distributed_context.rb +0 -24
  51. data/lib/opentelemetry/distributed_context/entry.rb +0 -66
  52. data/lib/opentelemetry/distributed_context/propagation.rb +0 -19
  53. data/lib/opentelemetry/distributed_context/propagation/binary_format.rb +0 -26
  54. data/lib/opentelemetry/distributed_context/propagation/text_format.rb +0 -76
  55. data/lib/opentelemetry/distributed_context/propagation/trace_parent.rb +0 -124
  56. data/lib/opentelemetry/internal.rb +0 -22
  57. data/lib/opentelemetry/trace/event.rb +0 -45
  58. data/lib/opentelemetry/trace/sampling_hint.rb +0 -22
  59. data/lib/opentelemetry/trace/tracer_factory.rb +0 -45
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 48050ae87a672b7a5e9ee6b28cd7b78d5affc75ddc4fca38b5fce29be29c667a
4
- data.tar.gz: b0227255a1f374fe2916110495cbe867dad595f1134f2a1ba536bb19493daa85
3
+ metadata.gz: 538ed3a78ed2551d82e647c361b94afc77a083a1126093cb26674e324197d0a0
4
+ data.tar.gz: eb5a65a102585407772dcc8b57b375c83198cbddc432c97a71d9fdef97e3171a
5
5
  SHA512:
6
- metadata.gz: 1a75c86cb6407d28a58e573d06b5faa7b3ea67d3a8dd3fdd6b45dc0d40d5122326bdb0de0d7be2e86aa1f0ec853589a28103e880fc22cf3882d2159064077832
7
- data.tar.gz: 48aebdd8a8260daade30c068486eb2618e82e80807aa74f38398ad557f4735e7608629b44c59884b9794d306c5e1570b2a888f13df35dd1f1ee0635a7acc185f
6
+ metadata.gz: '097a3f2d32207a56ba207cc2918f24e4eee28483117c54ed0412e83e617922980f385bf5c1949a91b232c4fa4a5bfccf5c66947ee65fc4ebc26460a27a33f6b6'
7
+ data.tar.gz: 533897d0cea9a0f731e4d7badf100089fb2bb87e95cbe28060e222aea4137272a4e71f9dd65e12ef8a8558bf3635cc512e663de2d5364fea9a1086cab3a9cef1
@@ -0,0 +1,9 @@
1
+ --no-private
2
+ --title=OpenTelemetry API
3
+ --markup=markdown
4
+ --main=OVERVIEW.md
5
+ ./lib/opentelemetry/**/*.rb
6
+ ./lib/opentelemetry.rb
7
+ -
8
+ OVERVIEW.md
9
+ CHANGELOG.md
@@ -1 +1,14 @@
1
1
  # Release History: opentelemetry-api
2
+
3
+ ### v0.6.0 / 2020-09-10
4
+
5
+ * ADDED: Add support for OTEL_LOG_LEVEL env var
6
+ * Documented array valued attributes [#343](https://github.com/open-telemetry/opentelemetry-ruby/pull/343)
7
+ * Renamed CorrelationContext to Baggage [#338](https://github.com/open-telemetry/opentelemetry-ruby/pull/338)
8
+ * Renamed Text* to TextMap* (propagators) [#335](https://github.com/open-telemetry/opentelemetry-ruby/pull/335)
9
+ * Fixed exception semantic conventions (`span.record_error` -> `span.record_exception`) [#333](https://github.com/open-telemetry/opentelemetry-ruby/pull/333)
10
+ * Removed support for lazy event creation [#329](https://github.com/open-telemetry/opentelemetry-ruby/pull/329)
11
+ * `name:` named parameter to `span.add_event` becomes first positional argument
12
+ * `Event` class removed from API
13
+ * Added `hex_trace_id` and `hex_span_id` helpers to `SpanContext` [#332](https://github.com/open-telemetry/opentelemetry-ruby/pull/332)
14
+ * Added `CorrelationContext::Manager.values` method to return correlations as a `Hash` [#323](https://github.com/open-telemetry/opentelemetry-ruby/pull/323)
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 [yyyy] [name of copyright owner]
189
+ Copyright 2020 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.
@@ -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
@@ -4,9 +4,4 @@
4
4
  #
5
5
  # SPDX-License-Identifier: Apache-2.0
6
6
 
7
- module OpenTelemetry
8
- module DistributedContext
9
- class Manager
10
- end
11
- end
12
- end
7
+ require 'opentelemetry'
@@ -1,43 +1,61 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2019 OpenTelemetry Authors
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/distributed_context'
11
- require 'opentelemetry/internal'
11
+ require 'opentelemetry/baggage'
12
+ require_relative './opentelemetry/instrumentation'
12
13
  require 'opentelemetry/metrics'
13
14
  require 'opentelemetry/trace'
14
15
  require 'opentelemetry/version'
15
16
 
16
- # OpenTelemetry provides global accessors for telemetry objects
17
+ # OpenTelemetry is an open source observability framework, providing a
18
+ # general-purpose API, SDK, and related tools required for the instrumentation
19
+ # of cloud-native software, frameworks, and libraries.
20
+ #
21
+ # The OpenTelemetry module provides global accessors for telemetry objects.
17
22
  module OpenTelemetry
18
23
  extend self
19
24
 
20
- attr_writer :tracer_factory, :meter_factory, :distributed_context_manager
25
+ attr_writer :tracer_provider, :meter_provider, :baggage, :logger
26
+
27
+ # @return [Object, Logger] configured Logger or a default STDOUT Logger.
28
+ def logger
29
+ @logger ||= Logger.new(STDOUT, level: ENV['OTEL_LOG_LEVEL'] || Logger::INFO)
30
+ end
21
31
 
22
- attr_accessor :logger
32
+ # @return [Object, Trace::TracerProvider] registered tracer provider or a
33
+ # default no-op implementation of the tracer provider.
34
+ def tracer_provider
35
+ @tracer_provider ||= Trace::TracerProvider.new
36
+ end
23
37
 
24
- # @return [Object, Trace::TracerFactory] registered tracer factory or a
25
- # default no-op implementation of the tracer factory.
26
- def tracer_factory
27
- @tracer_factory ||= Trace::TracerFactory.new
38
+ # @return [Object, Metrics::MeterProvider] registered meter provider or a
39
+ # default no-op implementation of the meter provider.
40
+ def meter_provider
41
+ @meter_provider ||= Metrics::MeterProvider.new
28
42
  end
29
43
 
30
- # @return [Object, Metrics::MeterFactory] registered meter factory or a
31
- # default no-op implementation of the meter factory.
32
- def meter_factory
33
- @meter_factory ||= Metrics::MeterFactory.new
44
+ # @return [Instrumentation::Registry] registry containing all known
45
+ # instrumentation
46
+ def instrumentation_registry
47
+ @instrumentation_registry ||= Instrumentation::Registry.new
34
48
  end
35
49
 
36
- # @return [Object, DistributedContext::Manager] registered distributed
37
- # context manager or a default no-op implementation of the manager
38
- def distributed_context_manager
39
- @distributed_context_manager ||= DistributedContext::Manager.new
50
+ # @return [Object, Baggage::Manager] registered
51
+ # baggage manager or a default no-op implementation of the
52
+ # manager.
53
+ def baggage
54
+ @baggage ||= Baggage::Manager.new
40
55
  end
41
56
 
42
- self.logger = Logger.new(STDOUT)
57
+ # @return [Context::Propagation::Propagation] an instance of the propagation API
58
+ def propagation
59
+ @propagation ||= Context::Propagation::Propagation.new
60
+ end
43
61
  end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2019 OpenTelemetry Authors
4
+ #
5
+ # SPDX-License-Identifier: Apache-2.0
6
+
7
+ require 'opentelemetry/baggage/builder'
8
+ require 'opentelemetry/baggage/manager'
9
+ require 'opentelemetry/baggage/propagation'
10
+
11
+ module OpenTelemetry
12
+ # The Baggage module provides functionality to record and propagate
13
+ # baggage in a distributed trace
14
+ module Baggage
15
+ end
16
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2019 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 Builder
11
+ def set_value(key, value); end
12
+
13
+ def remove_value(key); end
14
+
15
+ def clear; end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2019 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 Manager
11
+ NOOP_BUILDER = Builder.new
12
+ EMPTY_VALUES = {}.freeze
13
+ private_constant(:NOOP_BUILDER, :EMPTY_VALUES)
14
+
15
+ def build(context: Context.current)
16
+ yield NOOP_BUILDER
17
+ context
18
+ end
19
+
20
+ def set_value(key, value, 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_VALUES
30
+ end
31
+
32
+ def remove_value(key, context: Context.current)
33
+ context
34
+ end
35
+
36
+ def clear(context: Context.current)
37
+ context
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2019 OpenTelemetry Authors
4
+ #
5
+ # SPDX-License-Identifier: Apache-2.0
6
+
7
+ require 'opentelemetry/baggage/propagation/context_keys'
8
+ require 'opentelemetry/baggage/propagation/text_map_injector'
9
+ require 'opentelemetry/baggage/propagation/text_map_extractor'
10
+
11
+ module OpenTelemetry
12
+ module Baggage
13
+ # The Baggage::Propagation module contains injectors and
14
+ # extractors for sending and receiving baggage over the wire
15
+ module Propagation
16
+ extend self
17
+
18
+ TEXT_MAP_EXTRACTOR = TextMapExtractor.new
19
+ 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
+
27
+ private_constant :TEXT_MAP_INJECTOR, :TEXT_MAP_EXTRACTOR, :RACK_INJECTOR,
28
+ :RACK_EXTRACTOR
29
+
30
+ # Returns an extractor that extracts context using the W3C Baggage
31
+ # format
32
+ def text_map_injector
33
+ TEXT_MAP_INJECTOR
34
+ end
35
+
36
+ # Returns an injector that injects context using the W3C Baggage
37
+ # format
38
+ def text_map_extractor
39
+ TEXT_MAP_EXTRACTOR
40
+ 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
+ end
56
+ end
57
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2019 OpenTelemetry Authors
4
+ #
5
+ # SPDX-License-Identifier: Apache-2.0
6
+
7
+ module OpenTelemetry
8
+ module Baggage
9
+ module Propagation
10
+ # The ContextKeys module contains the keys used to index baggage
11
+ # in a {Context} instance
12
+ module ContextKeys
13
+ extend self
14
+
15
+ BAGGAGE_KEY = Context.create_key('baggage')
16
+ private_constant :BAGGAGE_KEY
17
+
18
+ # Returns the context key that baggage are indexed by
19
+ #
20
+ # @return [Context::Key]
21
+ def baggage_key
22
+ BAGGAGE_KEY
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2019 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
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2019 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
+ # Injects baggage using the W3C Baggage format
13
+ class TextMapInjector
14
+ include Context::Propagation::DefaultSetter
15
+
16
+ # Returns a new TextMapInjector that injects context using the specified
17
+ # header key
18
+ #
19
+ # @param [String] baggage_header_key The baggage header
20
+ # key used in the carrier
21
+ # @return [TextMapInjector]
22
+ def initialize(baggage_key: 'baggage')
23
+ @baggage_key = baggage_key
24
+ end
25
+
26
+ # Inject in-process baggage into the supplied carrier.
27
+ #
28
+ # @param [Carrier] carrier The carrier to inject baggage into
29
+ # @param [Context] context The context to read baggage from
30
+ # @param [optional Callable] getter An optional callable that takes a carrier and a key and
31
+ # returns the value associated with the key. If omitted the default getter will be used
32
+ # which expects the carrier to respond to [] and []=.
33
+ # @yield [Carrier, String] if an optional getter is provided, inject will yield the carrier
34
+ # and the header key to the getter.
35
+ # @return [Object] carrier with injected baggage
36
+ def inject(carrier, context, &setter)
37
+ return carrier unless (baggage = context[ContextKeys.baggage_key]) && !baggage.empty?
38
+
39
+ setter ||= default_setter
40
+ setter.call(carrier, @baggage_key, encode(baggage))
41
+
42
+ carrier
43
+ end
44
+
45
+ private
46
+
47
+ def encode(baggage)
48
+ baggage.inject(+'') do |memo, (k, v)|
49
+ memo << CGI.escape(k.to_s) << '=' << CGI.escape(v.to_s) << ','
50
+ end.chop!
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end