opentelemetry-sdk 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 (41) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +9 -0
  3. data/CHANGELOG.md +23 -0
  4. data/LICENSE +1 -1
  5. data/README.md +73 -0
  6. data/lib/opentelemetry-sdk.rb +7 -0
  7. data/lib/opentelemetry/sdk.rb +51 -0
  8. data/lib/opentelemetry/sdk/baggage.rb +16 -0
  9. data/lib/opentelemetry/sdk/baggage/builder.rb +40 -0
  10. data/lib/opentelemetry/sdk/baggage/manager.rb +97 -0
  11. data/lib/opentelemetry/sdk/configurator.rb +172 -0
  12. data/lib/opentelemetry/sdk/instrumentation_library.rb +13 -0
  13. data/lib/opentelemetry/sdk/internal.rb +21 -1
  14. data/lib/opentelemetry/sdk/resources.rb +1 -0
  15. data/lib/opentelemetry/sdk/resources/constants.rb +124 -0
  16. data/lib/opentelemetry/sdk/resources/resource.rb +39 -19
  17. data/lib/opentelemetry/sdk/trace.rb +2 -1
  18. data/lib/opentelemetry/sdk/trace/config/trace_config.rb +3 -3
  19. data/lib/opentelemetry/sdk/trace/event.rb +48 -0
  20. data/lib/opentelemetry/sdk/trace/export.rb +2 -7
  21. data/lib/opentelemetry/sdk/trace/export/batch_span_processor.rb +41 -35
  22. data/lib/opentelemetry/sdk/trace/export/console_span_exporter.rb +1 -1
  23. data/lib/opentelemetry/sdk/trace/export/in_memory_span_exporter.rb +7 -7
  24. data/lib/opentelemetry/sdk/trace/export/multi_span_exporter.rb +8 -14
  25. data/lib/opentelemetry/sdk/trace/export/noop_span_exporter.rb +4 -4
  26. data/lib/opentelemetry/sdk/trace/export/simple_span_processor.rb +10 -1
  27. data/lib/opentelemetry/sdk/trace/multi_span_processor.rb +12 -1
  28. data/lib/opentelemetry/sdk/trace/noop_span_processor.rb +10 -1
  29. data/lib/opentelemetry/sdk/trace/samplers.rb +48 -57
  30. data/lib/opentelemetry/sdk/trace/samplers/constant_sampler.rb +33 -0
  31. data/lib/opentelemetry/sdk/trace/samplers/decision.rb +3 -3
  32. data/lib/opentelemetry/sdk/trace/samplers/parent_based.rb +53 -0
  33. data/lib/opentelemetry/sdk/trace/samplers/result.rb +4 -3
  34. data/lib/opentelemetry/sdk/trace/samplers/trace_id_ratio_based.rb +45 -0
  35. data/lib/opentelemetry/sdk/trace/span.rb +39 -28
  36. data/lib/opentelemetry/sdk/trace/span_data.rb +18 -2
  37. data/lib/opentelemetry/sdk/trace/tracer.rb +26 -15
  38. data/lib/opentelemetry/sdk/trace/{tracer_factory.rb → tracer_provider.rb} +9 -9
  39. data/lib/opentelemetry/sdk/version.rb +1 -1
  40. metadata +20 -8
  41. data/lib/opentelemetry/sdk/trace/samplers/probability_sampler.rb +0 -74
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5ec567bdc317284ee832998232c68645a334e361aa25525901d2054982fe1390
4
- data.tar.gz: c82ce9e13256fd7e70937f806a11fae72798748e92bdb68b587a6aaa2274f00e
3
+ metadata.gz: 3a01fcf121db23108ffb47d196f9594993018bb1b945242710620bb87daa8320
4
+ data.tar.gz: ef3b3e9cd4e2853a22ffb149e7a18cbd021988412d24c40350192e222b3be58b
5
5
  SHA512:
6
- metadata.gz: 1417b975acd7e5006b58c34341f464db4ba809b8664ff0282cc1c7b6caac54358c33691a04dadf78ae1df8323cbb8f8dc8b10bd33da4326fb57ee0c293279f6c
7
- data.tar.gz: 1b2c01c8f77f936cdc9c144f8b1237f7ca46fa92a657bbc0d0824288bde5c3ba49914761f7181630c49c43d843b3c6e39bf33bda30147530f156c6f82e79f63e
6
+ metadata.gz: 5da08d0e902ece66efc7afa892f99f2b9fe3bcd5b89b51cd3da1a565a23ab0917eb1c39d6fb44ed6b82a71048624cb357539d9b6305b1a0c8debc594ef2467d3
7
+ data.tar.gz: 5fe47387c0d91e8d5436be4d4464839f08a9ae46964e8fe1679ab6ef7e7bf8b7a59ae086472d465e6f12c57b70c712a982064351f287a8ebbb6bbe173c37b45d
@@ -0,0 +1,9 @@
1
+ --no-private
2
+ --title=OpenTelemetry SDK
3
+ --markup=markdown
4
+ --main=OVERVIEW.md
5
+ ./lib/opentelemetry/sdk/**/*.rb
6
+ ./lib/opentelemetry/sdk.rb
7
+ -
8
+ OVERVIEW.md
9
+ CHANGELOG.md
@@ -1 +1,24 @@
1
1
  # Release History: opentelemetry-sdk
2
+
3
+ ### v0.6.0 / 2020-09-10
4
+
5
+ * BREAKING CHANGE: Rename Resource labels to attributes
6
+ * BREAKING CHANGE: Export resource from Span/SpanData instead of library_resource
7
+ * BREAKING CHANGE: Rename CorrelationContext to Baggage
8
+ * BREAKING CHANGE: Rename Text* to TextMap* (propagators, injectors, extractors)
9
+ * BREAKING CHANGE: Rename span.record_error to span.record_exception
10
+ * BREAKING CHANGE: Update samplers to match spec
11
+ * BREAKING CHANGE: Remove support for lazy event creation
12
+
13
+ * ADDED: Add OTLP exporter
14
+ * ADDED: Add support for OTEL_LOG_LEVEL env var
15
+ * FIXED: Rename Resource labels to attributes
16
+ * ADDED: Environment variable resource detection
17
+ * ADDED: BatchSpanProcessor environment variable support
18
+ * FIXED: Remove semver prefix
19
+ * FIXED: Docs for array valued attributes
20
+ * ADDED: Add hex_trace_id and hex_span_id helpers to SpanData
21
+ * FIXED: Fix ProbabilitySampler
22
+ * ADDED: Implement GetCorrelations
23
+ * FIXED: Change default Sampler to ParentOrElse(AlwaysOn)
24
+ * FIXED: Fix probability sampler
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,73 @@
1
+ # opentelemetry-sdk
2
+
3
+ The `opentelemetry-sdk` gem provides the reference implementation of the OpenTelemetry Ruby API. Using `opentelemetry-sdk`, an application can collect, analyze, and export 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-sdk` gem provides the reference implementation of the OpenTelemetry Ruby interfaces defined in the `opentelemetry-api` gem. That is, it includes the *functionality* needed to collect, analyze, and export telemetry data produced using the API.
14
+
15
+ Generally, Ruby *applications* should install `opentelemetry-sdk` (or other concrete implementation of the OpenTelemetry API). Using the SDK, an application can configure how it wants telemetry data to be handled, including which data should be persisted, how it should be formatted, and where it should be recorded or exported. However, *libraries* that produce telemetry data should generally 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-sdk
23
+ ```
24
+
25
+ Or, if you use [bundler][bundler-home], include `opentelemetry-sdk` in your `Gemfile`.
26
+
27
+ Then, configure the SDK according to your desired handling of telemetry data, and use the OpenTelemetry interfaces to produces traces and other information. Following is a basic example.
28
+
29
+ ```ruby
30
+ require 'opentelemetry/sdk'
31
+
32
+ # Configure the sdk with default export and context propagation formats
33
+ # see SDK#configure for customizing the setup
34
+ OpenTelemetry::SDK.configure
35
+
36
+ # To start a trace you need to get a Tracer from the TracerProvider
37
+ tracer = OpenTelemetry.tracer_provider.tracer('my_app_or_gem', '0.1.0')
38
+
39
+ # create a span
40
+ tracer.in_span('foo') do |span|
41
+ # set an attribute
42
+ span.set_attribute('platform', 'osx')
43
+ # add an event
44
+ span.add_event('event in bar')
45
+ # create bar as child of foo
46
+ tracer.in_span('bar') do |child_span|
47
+ # inspect the span
48
+ pp child_span
49
+ end
50
+ end
51
+ ```
52
+
53
+ For additional examples, see the [examples on github][examples-github].
54
+
55
+ ## How can I get involved?
56
+
57
+ The `opentelemetry-sdk` gem source is [on github][repo-github], along with related gems including `opentelemetry-api`.
58
+
59
+ 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].
60
+
61
+ ## License
62
+
63
+ The `opentelemetry-sdk` gem is distributed under the Apache 2.0 license. See [LICENSE][license-github] for more information.
64
+
65
+
66
+ [opentelemetry-home]: https://opentelemetry.io
67
+ [bundler-home]: https://bundler.io
68
+ [repo-github]: https://github.com/open-telemetry/opentelemetry-ruby
69
+ [license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/master/LICENSE
70
+ [examples-github]: https://github.com/open-telemetry/opentelemetry-ruby/tree/master/examples
71
+ [ruby-sig]: https://github.com/open-telemetry/community#ruby-sig
72
+ [community-meetings]: https://github.com/open-telemetry/community#community-meetings
73
+ [ruby-gitter]: https://gitter.im/open-telemetry/opentelemetry-ruby
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2019 OpenTelemetry Authors
4
+ #
5
+ # SPDX-License-Identifier: Apache-2.0
6
+
7
+ require 'opentelemetry/sdk'
@@ -6,13 +6,64 @@
6
6
 
7
7
  require 'opentelemetry'
8
8
 
9
+ # OpenTelemetry is an open source observability framework, providing a
10
+ # general-purpose API, SDK, and related tools required for the instrumentation
11
+ # of cloud-native software, frameworks, and libraries.
12
+ #
13
+ # The OpenTelemetry module provides global accessors for telemetry objects.
14
+ # See the documentation for the `opentelemetry-api` gem for details.
9
15
  module OpenTelemetry
10
16
  # SDK provides the reference implementation of the OpenTelemetry API.
11
17
  module SDK
18
+ extend self
19
+
20
+ # Configures SDK and instrumentation
21
+ #
22
+ # @yieldparam [Configurator] configurator Yields a configurator to the
23
+ # provided block
24
+ #
25
+ # Example usage:
26
+ # Without a block defaults are installed without any instrumentation
27
+ #
28
+ # OpenTelemetry::SDK.configure
29
+ #
30
+ # Install instrumentation individually with optional config
31
+ #
32
+ # OpenTelemetry::SDK.configure do |c|
33
+ # c.use 'OpenTelemetry::Instrumentation::Faraday', tracer_middleware: SomeMiddleware
34
+ # end
35
+ #
36
+ # Install all instrumentation with optional config
37
+ #
38
+ # OpenTelemetry::SDK.configure do |c|
39
+ # c.use_all 'OpenTelemetry::Instrumentation::Faraday' => { tracer_middleware: SomeMiddleware }
40
+ # end
41
+ #
42
+ # Add a span processor
43
+ #
44
+ # OpenTelemetry::SDK.configure do |c|
45
+ # c.add_span_processor SpanProcessor.new(SomeExporter.new)
46
+ # end
47
+ #
48
+ # Configure everything
49
+ #
50
+ # OpenTelemetry::SDK.configure do |c|
51
+ # c.logger = Logger.new('/dev/null')
52
+ # c.add_span_processor SpanProcessor.new(SomeExporter.new)
53
+ # c.use_all
54
+ # end
55
+ def configure
56
+ configurator = Configurator.new
57
+ yield configurator if block_given?
58
+ configurator.configure
59
+ end
12
60
  end
13
61
  end
14
62
 
63
+ require 'opentelemetry/sdk/configurator'
64
+ require 'opentelemetry/sdk/baggage'
15
65
  require 'opentelemetry/sdk/internal'
66
+ require 'opentelemetry/sdk/instrumentation_library'
16
67
  require 'opentelemetry/sdk/resources'
17
68
  require 'opentelemetry/sdk/trace'
18
69
  require 'opentelemetry/sdk/version'
@@ -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/sdk/baggage/builder'
8
+ require 'opentelemetry/sdk/baggage/manager'
9
+
10
+ module OpenTelemetry
11
+ module SDK
12
+ # Contains operational implementations of the Baggage::Manager
13
+ module Baggage
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,40 @@
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 SDK
9
+ module Baggage
10
+ # SDK implementation of Baggage::Builder
11
+ class Builder
12
+ attr_reader :entries
13
+
14
+ def initialize(entries)
15
+ @entries = entries
16
+ end
17
+
18
+ # Set key-value in the to-be-created baggage
19
+ #
20
+ # @param [String] key The key to store this value under
21
+ # @param [String] value String value to be stored under key
22
+ def set_value(key, value)
23
+ @entries[key] = value.to_s
24
+ end
25
+
26
+ # Removes key from the to-be-created baggage
27
+ #
28
+ # @param [String] key The key to remove
29
+ def remove_value(key)
30
+ @entries.delete(key)
31
+ end
32
+
33
+ # Clears all baggage from the to-be-created baggage
34
+ def clear
35
+ @entries.clear
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,97 @@
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 SDK
9
+ module Baggage
10
+ # Manages baggage
11
+ class Manager
12
+ BAGGAGE_KEY = OpenTelemetry::Baggage::Propagation::ContextKeys.baggage_key
13
+ EMPTY_BAGGAGE = {}.freeze
14
+ private_constant(:BAGGAGE_KEY, :EMPTY_BAGGAGE)
15
+
16
+ # Used to chain modifications to baggage. The result is a
17
+ # context with an updated baggage. If only a single
18
+ # modification is being made to baggage, use the other
19
+ # methods on +Manager+, if multiple modifications are being made, use
20
+ # this one.
21
+ #
22
+ # @param [optional Context] context The context to update with with new
23
+ # modified baggage. Defaults to +Context.current+
24
+ # @return [Context]
25
+ def build_context(context: Context.current)
26
+ builder = Builder.new(baggage_for(context).dup)
27
+ yield builder
28
+ context.set_value(BAGGAGE_KEY, builder.entries)
29
+ end
30
+
31
+ # Returns a new context with empty baggage
32
+ #
33
+ # @param [optional Context] context Context to clear baggage from. Defaults
34
+ # to +Context.current+
35
+ # @return [Context]
36
+ def clear(context: Context.current)
37
+ context.set_value(BAGGAGE_KEY, EMPTY_BAGGAGE)
38
+ end
39
+
40
+ # Returns the corresponding baggage value (or nil) for key
41
+ #
42
+ # @param [String] key The lookup key
43
+ # @param [optional Context] context The context from which to retrieve
44
+ # the key.
45
+ # Defaults to +Context.current+
46
+ # @return [String]
47
+ def value(key, context: Context.current)
48
+ baggage_for(context)[key]
49
+ end
50
+
51
+ # Returns the baggage
52
+ #
53
+ # @param [optional Context] context The context from which to retrieve
54
+ # the baggage.
55
+ # Defaults to +Context.current+
56
+ # @return [Hash]
57
+ def values(context: Context.current)
58
+ baggage_for(context).dup.freeze
59
+ end
60
+
61
+ # Returns a new context with new key-value pair
62
+ #
63
+ # @param [String] key The key to store this value under
64
+ # @param [String] value String value to be stored under key
65
+ # @param [optional Context] context The context to update with new
66
+ # value. Defaults to +Context.current+
67
+ # @return [Context]
68
+ def set_value(key, value, context: Context.current)
69
+ new_baggage = baggage_for(context).dup
70
+ new_baggage[key] = value
71
+ context.set_value(BAGGAGE_KEY, new_baggage)
72
+ end
73
+
74
+ # Returns a new context with value at key removed
75
+ #
76
+ # @param [String] key The key to remove
77
+ # @param [optional Context] context The context to remove baggage
78
+ # from. Defaults to +Context.current+
79
+ # @return [Context]
80
+ def remove_value(key, context: Context.current)
81
+ baggage = baggage_for(context)
82
+ return context unless baggage.key?(key)
83
+
84
+ new_baggage = baggage.dup
85
+ new_baggage.delete(key)
86
+ context.set_value(BAGGAGE_KEY, new_baggage)
87
+ end
88
+
89
+ private
90
+
91
+ def baggage_for(context)
92
+ context.value(BAGGAGE_KEY) || EMPTY_BAGGAGE
93
+ end
94
+ end
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,172 @@
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 SDK
9
+ # The configurator provides defaults and facilitates configuring the
10
+ # SDK for use.
11
+ class Configurator # rubocop:disable Metrics/ClassLength
12
+ USE_MODE_UNSPECIFIED = 0
13
+ USE_MODE_ONE = 1
14
+ USE_MODE_ALL = 2
15
+
16
+ private_constant :USE_MODE_UNSPECIFIED, :USE_MODE_ONE, :USE_MODE_ALL
17
+
18
+ attr_writer :logger, :http_extractors, :http_injectors, :text_map_extractors,
19
+ :text_map_injectors
20
+
21
+ def initialize
22
+ @instrumentation_names = []
23
+ @instrumentation_config_map = {}
24
+ @http_extractors = nil
25
+ @http_injectors = nil
26
+ @text_map_extractors = nil
27
+ @text_map_injectors = nil
28
+ @span_processors = []
29
+ @use_mode = USE_MODE_UNSPECIFIED
30
+ @resource = Resources::Resource.telemetry_sdk
31
+ end
32
+
33
+ def logger
34
+ @logger ||= OpenTelemetry.logger
35
+ end
36
+
37
+ # Accepts a resource object that is merged with the default telemetry sdk
38
+ # resource. The use of this method is optional, and is provided as means
39
+ # to include additional resource information.
40
+ # If a resource key collision occurs the passed in resource takes priority.
41
+ #
42
+ # @param [Resource] new_resource The resource to be merged
43
+ def resource=(new_resource)
44
+ @resource = new_resource.merge(@resource)
45
+ end
46
+
47
+ # Install an instrumentation with specificied optional +config+.
48
+ # Use can be called multiple times to install multiple instrumentation.
49
+ # Only +use+ or +use_all+, but not both when installing
50
+ # instrumentation. A call to +use_all+ after +use+ will result in an
51
+ # exception.
52
+ #
53
+ # @param [String] instrumentation_name The name of the instrumentation
54
+ # @param [optional Hash] config The config for this instrumentation
55
+ def use(instrumentation_name, config = nil)
56
+ check_use_mode!(USE_MODE_ONE)
57
+ @instrumentation_names << instrumentation_name
58
+ @instrumentation_config_map[instrumentation_name] = config if config
59
+ end
60
+
61
+ # Install all registered instrumentation. Configuration for specific
62
+ # instrumentation can be provided with the optional +instrumentation_config_map+
63
+ # parameter. Only +use+ or +use_all+, but not both when installing
64
+ # instrumentation. A call to +use+ after +use_all+ will result in an
65
+ # exception.
66
+ #
67
+ # @param [optional Hash<String,Hash>] instrumentation_config_map A map with string keys
68
+ # representing the instrumentation name and values specifying the instrumentation config
69
+ def use_all(instrumentation_config_map = {})
70
+ check_use_mode!(USE_MODE_ALL)
71
+ @instrumentation_config_map = instrumentation_config_map
72
+ end
73
+
74
+ # Add a span processor to the export pipeline
75
+ #
76
+ # @param [#on_start, #on_finish, #shutdown] span_processor A span_processor
77
+ # that satisfies the duck type #on_start, #on_finish, #shutdown. See
78
+ # {SimpleSpanProcessor} for an example.
79
+ def add_span_processor(span_processor)
80
+ @span_processors << span_processor
81
+ end
82
+
83
+ # @api private
84
+ # The configure method is where we define the setup process. This allows
85
+ # us to make certain guarantees about which systems and globals are setup
86
+ # at each stage. The setup process is:
87
+ # - setup logging
88
+ # - setup propagation
89
+ # - setup tracer_provider and meter_provider
90
+ # - install instrumentation
91
+ def configure
92
+ OpenTelemetry.logger = logger
93
+ OpenTelemetry.baggage = Baggage::Manager.new
94
+ configure_propagation
95
+ configure_span_processors
96
+ OpenTelemetry.tracer_provider = tracer_provider
97
+ install_instrumentation
98
+ end
99
+
100
+ private
101
+
102
+ def tracer_provider
103
+ @tracer_provider ||= Trace::TracerProvider.new(@resource)
104
+ end
105
+
106
+ def check_use_mode!(mode)
107
+ @use_mode = mode if @use_mode == USE_MODE_UNSPECIFIED
108
+ raise 'Use either `use_all` or `use`, but not both' unless @use_mode == mode
109
+ end
110
+
111
+ def install_instrumentation
112
+ case @use_mode
113
+ when USE_MODE_ONE
114
+ OpenTelemetry.instrumentation_registry.install(@instrumentation_names, @instrumentation_config_map)
115
+ when USE_MODE_ALL
116
+ OpenTelemetry.instrumentation_registry.install_all(@instrumentation_config_map)
117
+ end
118
+ end
119
+
120
+ def configure_span_processors
121
+ processors = @span_processors.empty? ? [default_span_processor] : @span_processors
122
+ processors.each { |p| tracer_provider.add_span_processor(p) }
123
+ end
124
+
125
+ def default_span_processor
126
+ Trace::Export::SimpleSpanProcessor.new(
127
+ Trace::Export::ConsoleSpanExporter.new
128
+ )
129
+ end
130
+
131
+ def configure_propagation
132
+ OpenTelemetry.propagation.http = create_propagator(@http_injectors || default_http_injectors,
133
+ @http_extractors || default_http_extractors)
134
+ OpenTelemetry.propagation.text = create_propagator(@text_map_injectors || default_text_map_injectors,
135
+ @text_map_extractors || default_text_map_extractors)
136
+ end
137
+
138
+ def create_propagator(injectors, extractors)
139
+ if injectors.size > 1 || extractors.size > 1
140
+ Context::Propagation::CompositePropagator.new(injectors, extractors)
141
+ else
142
+ Context::Propagation::Propagator.new(injectors, extractors)
143
+ end
144
+ end
145
+
146
+ def default_http_injectors
147
+ default_text_map_injectors
148
+ end
149
+
150
+ def default_http_extractors
151
+ [
152
+ OpenTelemetry::Trace::Propagation::TraceContext.rack_extractor,
153
+ OpenTelemetry::Baggage::Propagation.rack_extractor
154
+ ]
155
+ end
156
+
157
+ def default_text_map_injectors
158
+ [
159
+ OpenTelemetry::Trace::Propagation::TraceContext.text_map_injector,
160
+ OpenTelemetry::Baggage::Propagation.text_map_injector
161
+ ]
162
+ end
163
+
164
+ def default_text_map_extractors
165
+ [
166
+ OpenTelemetry::Trace::Propagation::TraceContext.text_map_extractor,
167
+ OpenTelemetry::Baggage::Propagation.text_map_extractor
168
+ ]
169
+ end
170
+ end
171
+ end
172
+ end