opentelemetry-sdk 0.16.0 → 1.0.0.rc3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +133 -61
  3. data/README.md +25 -2
  4. data/lib/opentelemetry/sdk.rb +5 -3
  5. data/lib/opentelemetry/sdk/configurator.rb +54 -43
  6. data/lib/opentelemetry/sdk/forwarding_logger.rb +69 -0
  7. data/lib/opentelemetry/sdk/internal.rb +3 -3
  8. data/lib/opentelemetry/sdk/resources.rb +0 -1
  9. data/lib/opentelemetry/sdk/resources/resource.rb +16 -9
  10. data/lib/opentelemetry/sdk/trace.rb +2 -3
  11. data/lib/opentelemetry/sdk/trace/event.rb +7 -36
  12. data/lib/opentelemetry/sdk/trace/export.rb +3 -2
  13. data/lib/opentelemetry/sdk/trace/export/batch_span_processor.rb +4 -3
  14. data/lib/opentelemetry/sdk/trace/export/in_memory_span_exporter.rb +13 -4
  15. data/lib/opentelemetry/sdk/trace/export/simple_span_processor.rb +2 -0
  16. data/lib/opentelemetry/sdk/trace/export/{noop_span_exporter.rb → span_exporter.rb} +8 -7
  17. data/lib/opentelemetry/sdk/trace/span.rb +55 -39
  18. data/lib/opentelemetry/sdk/trace/span_data.rb +25 -18
  19. data/lib/opentelemetry/sdk/trace/span_limits.rb +60 -0
  20. data/lib/opentelemetry/sdk/trace/{noop_span_processor.rb → span_processor.rb} +5 -8
  21. data/lib/opentelemetry/sdk/trace/tracer.rb +1 -37
  22. data/lib/opentelemetry/sdk/trace/tracer_provider.rb +89 -19
  23. data/lib/opentelemetry/sdk/version.rb +1 -1
  24. metadata +74 -24
  25. data/lib/opentelemetry/sdk/baggage.rb +0 -16
  26. data/lib/opentelemetry/sdk/baggage/builder.rb +0 -40
  27. data/lib/opentelemetry/sdk/baggage/manager.rb +0 -97
  28. data/lib/opentelemetry/sdk/resources/constants.rb +0 -205
  29. data/lib/opentelemetry/sdk/trace/config.rb +0 -18
  30. data/lib/opentelemetry/sdk/trace/config/trace_config.rb +0 -79
  31. data/lib/opentelemetry/sdk/trace/export/multi_span_exporter.rb +0 -76
  32. data/lib/opentelemetry/sdk/trace/multi_span_processor.rb +0 -86
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0231dc6f06956325ffb14fc4a209f579001c7cc059659da14d4a4790fd07efeb
4
- data.tar.gz: 676299747265e10f02eb15ffda455bfcd70155a9969e1f021804fb37c26ba768
3
+ metadata.gz: 17f7b73252b2a5e788e9e47e25d7ade10d5694481c2486751aa95f993ea61496
4
+ data.tar.gz: 1c9774adc9d2ae03b82e62d5c403cce431c8d3b301233985c88c286b93155666
5
5
  SHA512:
6
- metadata.gz: ea3a1003fd132137846cbf7957da2524e21dca19d0899c9663cebbc5836bd5ce1adafe4b0ecf8f899600a94701b410534ea1eca56409da9e2dc3de658b0cb4c7
7
- data.tar.gz: ee4b4487c397cee00f0d40854c3c19b7e405bfff70f145ee8520f1ceb924ac7a99cb8b15a43af30c826f59d08028345ab62535d5fef0164c89e43bd6b221d43c
6
+ metadata.gz: e586c8e065502a1651577c3389868a056b3f1146bd08567a721264367e7391b8af257c30401ec99333e63c18b8cb0f8ea9526ac5f24aeded17918e53600fe5a6
7
+ data.tar.gz: b5473a3c7be5039721c883bbbdb834db9ee1821d15e69287cf6a690a607dbc2ee99c267741260368315abdf4adc5a0ae3724351e2897d5119615fae56bf42a14
data/CHANGELOG.md CHANGED
@@ -1,113 +1,185 @@
1
1
  # Release History: opentelemetry-sdk
2
2
 
3
+ ### v1.0.0.rc3 / 2021-08-12
4
+
5
+ * BREAKING CHANGE: Remove optional parent_context from in_span
6
+ * BREAKING CHANGE: Replace Time.now with Process.clock_gettime
7
+ * BREAKING CHANGE: Refactor Baggage to remove Noop*
8
+ * BREAKING CHANGE: Remove unnecessary readers from SDK Tracer
9
+ * BREAKING CHANGE: Total order constraint on span.status=
10
+ * BREAKING CHANGE: Use auto-generated resource constants in sdk and resource_detectors
11
+ * BREAKING CHANGE: Span limits env vars
12
+
13
+ * ADDED: Add Tracer.non_recording_span to API
14
+ * ADDED: Add unnamed tracer warning message
15
+ * ADDED: Allow disabling of install messages
16
+ * ADDED: Make API's NoopTextMapPropagator private
17
+ * ADDED: Use auto-generated resource constants in sdk and resource_detectors
18
+ * ADDED: Allow selecting multiple exporter
19
+ * ADDED: Add explicit BSP export error
20
+ * FIXED: Remove optional parent_context from in_span
21
+ * FIXED: Replace Time.now with Process.clock_gettime
22
+ * FIXED: Rename cloud.zone to cloud.availability_zone
23
+ * FIXED: Improve attribute error messages
24
+ * FIXED: Refactor Baggage to remove Noop*
25
+ * FIXED: Support OTEL_SERVICE_NAME env var
26
+ * FIXED: Remove unnecessary readers from SDK Tracer
27
+ * FIXED: Total order constraint on span.status=
28
+ * FIXED: Flakey tracer provider test
29
+ * FIXED: Split lock in TracerProvider
30
+ * FIXED: Span limits env vars
31
+ * FIXED: Prune invalid links
32
+ * DOCS: Update docs to rely more on environment variable configuration
33
+
34
+ ### v1.0.0.rc2 / 2021-06-23
35
+
36
+ * BREAKING CHANGE: Remove optional parent_context from in_span [729](https://github.com/open-telemetry/opentelemetry-ruby/pull/729)
37
+ * BREAKING CHANGE: Replace Time.now with Process.clock_gettime [717](https://github.com/open-telemetry/opentelemetry-ruby/pull/717)
38
+ * BREAKING CHANGE: Refactor Baggage to remove Noop* [800](https://github.com/open-telemetry/opentelemetry-ruby/pull/800)
39
+ * BREAKING CHANGE: Remove unnecessary readers from SDK Tracer [820](https://github.com/open-telemetry/opentelemetry-ruby/pull/820)
40
+ - Tracer no longer surfaces attribute readers for the name, version, or tracer_provider
41
+ * BREAKING CHANGE: Total order constraint on span.status= [805](https://github.com/open-telemetry/opentelemetry-ruby/pull/805)
42
+
43
+ * ADDED: Add Tracer.non_recording_span to API [799](https://github.com/open-telemetry/opentelemetry-ruby/pull/799)
44
+ * ADDED: Add unnamed tracer warning message [830](https://github.com/open-telemetry/opentelemetry-ruby/pull/830)
45
+ * ADDED: Allow disabling of install messages [831](https://github.com/open-telemetry/opentelemetry-ruby/pull/831)
46
+ * FIXED: Rename cloud.zone to cloud.availability_zone [734](https://github.com/open-telemetry/opentelemetry-ruby/pull/734)
47
+ * FIXED: Improve attribute error messages [742](https://github.com/open-telemetry/opentelemetry-ruby/pull/742)
48
+ * FIXED: Support OTEL_SERVICE_NAME env var [806]https://github.com/open-telemetry/opentelemetry-ruby/pull/806
49
+ * FIXED: Flakey tracer provider test
50
+
51
+ ### v1.0.0.rc1 / 2021-05-21
52
+
53
+ * BREAKING CHANGE: Remove optional parent_context from in_span
54
+ * BREAKING CHANGE: Replace Time.now with Process.clock_gettime
55
+
56
+ * FIXED: Remove optional parent_context from in_span
57
+ * FIXED: Replace Time.now with Process.clock_gettime
58
+ * FIXED: Rename cloud.zone to cloud.availability_zone
59
+ * FIXED: Improve attribute error messages
60
+
61
+ ### v0.17.0 / 2021-04-22
62
+
63
+ * BREAKING CHANGE: Replace TextMapInjector/TextMapExtractor pairs with a TextMapPropagator.
64
+
65
+ [Check the propagator documentation](https://open-telemetry.github.io/opentelemetry-ruby/) for the new usage.
66
+
67
+ * ADDED: Add zipkin exporter
68
+ * ADDED: Processors validate exporters on init.
69
+ * ADDED: Add configurable truncation of span and event attribute values
70
+ * ADDED: Add simple 'recording' attr_accessor to InMemorySpanExporter
71
+ * FIXED: Typo in error message
72
+ * FIXED: Improve configuration error reporting
73
+ * FIXED: Refactor propagators to add #fields
74
+
3
75
  ### v0.16.0 / 2021-03-17
4
76
 
5
- * BREAKING CHANGE: Update SDK BaggageManager to match API
6
- * BREAKING CHANGE: Implement Exporter#force_flush
77
+ * BREAKING CHANGE: Update SDK BaggageManager to match API
78
+ * BREAKING CHANGE: Implement Exporter#force_flush
7
79
 
8
- * ADDED: Add force_flush to SDK's TracerProvider
9
- * ADDED: Add k8s node to gcp resource detector
10
- * ADDED: Add console option for OTEL_TRACES_EXPORTER
11
- * ADDED: Span#add_attributes
12
- * ADDED: Implement Exporter#force_flush
13
- * FIXED: Update SDK BaggageManager to match API
14
- * DOCS: Replace Gitter with GitHub Discussions
80
+ * ADDED: Add force_flush to SDK's TracerProvider
81
+ * ADDED: Add k8s node to gcp resource detector
82
+ * ADDED: Add console option for OTEL_TRACES_EXPORTER
83
+ * ADDED: Span#add_attributes
84
+ * ADDED: Implement Exporter#force_flush
85
+ * FIXED: Update SDK BaggageManager to match API
86
+ * DOCS: Replace Gitter with GitHub Discussions
15
87
 
16
88
  ### v0.15.0 / 2021-02-18
17
89
 
18
- * BREAKING CHANGE: Streamline processor pipeline
90
+ * BREAKING CHANGE: Streamline processor pipeline
19
91
 
20
- * ADDED: Add instrumentation config validation
21
- * FIXED: Streamline processor pipeline
22
- * FIXED: OTEL_TRACE -> OTEL_TRACES env vars
23
- * FIXED: Change limits from 1000 to 128
24
- * FIXED: OTEL_TRACES_EXPORTER and OTEL_PROPAGATORS
25
- * FIXED: Add thread error handling to the BSP
26
- * DOCS: Clarify nil attribute values not allowed
92
+ * ADDED: Add instrumentation config validation
93
+ * FIXED: Streamline processor pipeline
94
+ * FIXED: OTEL_TRACE -> OTEL_TRACES env vars
95
+ * FIXED: Change limits from 1000 to 128
96
+ * FIXED: OTEL_TRACES_EXPORTER and OTEL_PROPAGATORS
97
+ * FIXED: Add thread error handling to the BSP
98
+ * DOCS: Clarify nil attribute values not allowed
27
99
 
28
100
  ### v0.14.0 / 2021-02-03
29
101
 
30
- * BREAKING CHANGE: Replace getter and setter callables and remove rack specific propagators
102
+ * BREAKING CHANGE: Replace getter and setter callables and remove rack specific propagators
31
103
 
32
- * ADDED: Replace getter and setter callables and remove rack specific propagators
104
+ * ADDED: Replace getter and setter callables and remove rack specific propagators
33
105
 
34
106
  ### v0.13.1 / 2021-02-01
35
107
 
36
- * FIXED: Leaky test
37
- * FIXED: Allow env var override of service.name
108
+ * FIXED: Leaky test
109
+ * FIXED: Allow env var override of service.name
38
110
 
39
111
  ### v0.13.0 / 2021-01-29
40
112
 
41
- * BREAKING CHANGE: Remove MILLIS from BatchSpanProcessor vars
113
+ * BREAKING CHANGE: Remove MILLIS from BatchSpanProcessor vars
42
114
 
43
- * ADDED: Process.runtime resource
44
- * ADDED: Provide default resource in SDK
45
- * ADDED: Add optional attributes to record_exception
46
- * FIXED: Resource.merge consistency
47
- * FIXED: Remove MILLIS from BatchSpanProcessor vars
115
+ * ADDED: Process.runtime resource
116
+ * ADDED: Provide default resource in SDK
117
+ * ADDED: Add optional attributes to record_exception
118
+ * FIXED: Resource.merge consistency
119
+ * FIXED: Remove MILLIS from BatchSpanProcessor vars
48
120
 
49
121
  ### v0.12.1 / 2021-01-13
50
122
 
51
- * FIXED: Fix several BatchSpanProcessor errors related to fork safety
52
- * FIXED: Define default value for traceid ratio
123
+ * FIXED: Fix several BatchSpanProcessor errors related to fork safety
124
+ * FIXED: Define default value for traceid ratio
53
125
 
54
126
  ### v0.12.0 / 2020-12-24
55
127
 
56
- * ADDED: Structured error handling
57
- * ADDED: Pluggable ID generation
58
- * FIXED: BSP dropped span buffer full reporting
59
- * FIXED: Implement SDK environment variables
60
- * FIXED: Remove incorrect TODO
128
+ * ADDED: Structured error handling
129
+ * ADDED: Pluggable ID generation
130
+ * FIXED: BSP dropped span buffer full reporting
131
+ * FIXED: Implement SDK environment variables
132
+ * FIXED: Remove incorrect TODO
61
133
 
62
134
  ### v0.11.1 / 2020-12-16
63
135
 
64
- * FIXED: BSP dropped span buffer full reporting
136
+ * FIXED: BSP dropped span buffer full reporting
65
137
 
66
138
  ### v0.11.0 / 2020-12-11
67
139
 
68
- * ADDED: Metrics reporting from trace export
69
- * FIXED: Copyright comments to not reference year
140
+ * ADDED: Metrics reporting from trace export
141
+ * FIXED: Copyright comments to not reference year
70
142
 
71
143
  ### v0.10.0 / 2020-12-03
72
144
 
73
- * BREAKING CHANGE: Allow samplers to modify tracestate
145
+ * BREAKING CHANGE: Allow samplers to modify tracestate
74
146
 
75
- * FIXED: Allow samplers to modify tracestate
147
+ * FIXED: Allow samplers to modify tracestate
76
148
 
77
149
  ### v0.9.0 / 2020-11-27
78
150
 
79
- * BREAKING CHANGE: Pass full Context to samplers
80
- * BREAKING CHANGE: Add timeout for force_flush and shutdown
151
+ * BREAKING CHANGE: Pass full Context to samplers
152
+ * BREAKING CHANGE: Add timeout for force_flush and shutdown
81
153
 
82
- * ADDED: Add OTEL_RUBY_BSP_START_THREAD_ON_BOOT env var
83
- * ADDED: Add timeout for force_flush and shutdown
84
- * FIXED: Signal at batch_size
85
- * FIXED: SDK Span.recording? after finish
86
- * FIXED: Pass full Context to samplers
87
- * DOCS: Add documentation on usage scenarios for span processors
154
+ * ADDED: Add OTEL_RUBY_BSP_START_THREAD_ON_BOOT env var
155
+ * ADDED: Add timeout for force_flush and shutdown
156
+ * FIXED: Signal at batch_size
157
+ * FIXED: SDK Span.recording? after finish
158
+ * FIXED: Pass full Context to samplers
159
+ * DOCS: Add documentation on usage scenarios for span processors
88
160
 
89
161
  ### v0.8.0 / 2020-10-27
90
162
 
91
- * BREAKING CHANGE: Move context/span methods to Trace module
92
- * BREAKING CHANGE: Remove 'canonical' from status codes
93
- * BREAKING CHANGE: Assorted SpanContext fixes
163
+ * BREAKING CHANGE: Move context/span methods to Trace module
164
+ * BREAKING CHANGE: Remove 'canonical' from status codes
165
+ * BREAKING CHANGE: Assorted SpanContext fixes
94
166
 
95
- * FIXED: Move context/span methods to Trace module
96
- * FIXED: Remove 'canonical' from status codes
97
- * FIXED: Assorted SpanContext fixes
167
+ * FIXED: Move context/span methods to Trace module
168
+ * FIXED: Remove 'canonical' from status codes
169
+ * FIXED: Assorted SpanContext fixes
98
170
 
99
171
  ### v0.7.0 / 2020-10-07
100
172
 
101
- * ADDED: Add service_name setter to configurator
102
- * ADDED: Add service_version setter to configurator
103
- * FIXED: Fork safety for batch processor
104
- * FIXED: Don't generate a span ID unnecessarily
105
- * DOCS: Fix Configurator#add_span_processor
106
- * DOCS: Standardize toplevel docs structure and readme
173
+ * ADDED: Add service_name setter to configurator
174
+ * ADDED: Add service_version setter to configurator
175
+ * FIXED: Fork safety for batch processor
176
+ * FIXED: Don't generate a span ID unnecessarily
177
+ * DOCS: Fix Configurator#add_span_processor
178
+ * DOCS: Standardize toplevel docs structure and readme
107
179
 
108
180
  ### v0.6.0 / 2020-09-10
109
181
 
110
- * BREAKING CHANGE: Rename Resource labels to attributes
182
+ * BREAKING CHANGE: Rename Resource labels to attributes
111
183
  * BREAKING CHANGE: Export resource from Span/SpanData instead of library_resource
112
184
  * BREAKING CHANGE: Rename CorrelationContext to Baggage
113
185
  * BREAKING CHANGE: Rename Text* to TextMap* (propagators, injectors, extractors)
@@ -117,7 +189,7 @@
117
189
 
118
190
  * ADDED: Add OTLP exporter
119
191
  * ADDED: Add support for OTEL_LOG_LEVEL env var
120
- * FIXED: Rename Resource labels to attributes
192
+ * FIXED: Rename Resource labels to attributes
121
193
  * ADDED: Environment variable resource detection
122
194
  * ADDED: BatchSpanProcessor environment variable support
123
195
  * FIXED: Remove semver prefix
data/README.md CHANGED
@@ -29,10 +29,33 @@ Then, configure the SDK according to your desired handling of telemetry data, an
29
29
  ```ruby
30
30
  require 'opentelemetry/sdk'
31
31
 
32
- # Configure the sdk with default export and context propagation formats
33
- # see SDK#configure for customizing the setup
32
+ # Configure the sdk with default export and context propagation formats.
34
33
  OpenTelemetry::SDK.configure
35
34
 
35
+ # Many configuration options may be set via the environment. To use them,
36
+ # set the appropriate variable before calling configure. For example:
37
+ #
38
+ # ENV['OTEL_TRACES_EXPORTER'] = 'console'
39
+ # ENV['OTEL_PROPAGATORS'] = 'ottrace'
40
+ # OpenTelemetry::SDK.configure
41
+ #
42
+ # You may also configure the SDK programmatically, for advanced usage or to
43
+ # enable auto-instrumentation. For example:
44
+ #
45
+ # OpenTelemetry::SDK.configure do |c|
46
+ # c.service_name = something_calculated_dynamically
47
+ # c.add_span_processor(
48
+ # OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(
49
+ # OpenTelemetry::SDK::Trace::Export::ConsoleSpanExporter.new
50
+ # )
51
+ # )
52
+ #
53
+ # c.use 'OpenTelemetry::Instrumentation::Net::HTTP'
54
+ # end
55
+ #
56
+ # Note that the SimpleSpanExporter is not recommended for use in production.
57
+
58
+
36
59
  # To start a trace you need to get a Tracer from the TracerProvider
37
60
  tracer = OpenTelemetry.tracer_provider.tracer('my_app_or_gem', '0.1.0')
38
61
 
@@ -6,6 +6,8 @@
6
6
 
7
7
  require 'opentelemetry'
8
8
  require 'opentelemetry/common'
9
+ require 'opentelemetry-instrumentation-base'
10
+ require 'opentelemetry-semantic_conventions'
9
11
 
10
12
  # OpenTelemetry is an open source observability framework, providing a
11
13
  # general-purpose API, SDK, and related tools required for the instrumentation
@@ -54,7 +56,7 @@ module OpenTelemetry
54
56
  # Configure everything
55
57
  #
56
58
  # OpenTelemetry::SDK.configure do |c|
57
- # c.logger = Logger.new('/dev/null')
59
+ # c.logger = Logger.new(File::NULL)
58
60
  # c.add_span_processor SpanProcessor.new(SomeExporter.new)
59
61
  # c.use_all
60
62
  # end
@@ -66,14 +68,14 @@ module OpenTelemetry
66
68
  begin
67
69
  raise ConfigurationError
68
70
  rescue ConfigurationError => e
69
- OpenTelemetry.handle_error(exception: e, message: 'unexpected configuration error')
71
+ OpenTelemetry.handle_error(exception: e, message: "unexpected configuration error due to #{e.cause}")
70
72
  end
71
73
  end
72
74
  end
73
75
  end
74
76
 
75
77
  require 'opentelemetry/sdk/configurator'
76
- require 'opentelemetry/sdk/baggage'
78
+ require 'opentelemetry/sdk/forwarding_logger'
77
79
  require 'opentelemetry/sdk/internal'
78
80
  require 'opentelemetry/sdk/instrumentation_library'
79
81
  require 'opentelemetry/sdk/resources'
@@ -9,20 +9,34 @@ module OpenTelemetry
9
9
  # The configurator provides defaults and facilitates configuring the
10
10
  # SDK for use.
11
11
  class Configurator # rubocop:disable Metrics/ClassLength
12
+ # @api private
13
+ class NoopTextMapPropagator
14
+ EMPTY_LIST = [].freeze
15
+ private_constant(:EMPTY_LIST)
16
+
17
+ def inject(carrier, context: Context.current, setter: Context::Propagation.text_map_setter); end
18
+
19
+ def extract(carrier, context: Context.current, getter: Context::Propagation.text_map_getter)
20
+ context
21
+ end
22
+
23
+ def fields
24
+ EMPTY_LIST
25
+ end
26
+ end
27
+
12
28
  USE_MODE_UNSPECIFIED = 0
13
29
  USE_MODE_ONE = 1
14
30
  USE_MODE_ALL = 2
15
31
 
16
32
  private_constant :USE_MODE_UNSPECIFIED, :USE_MODE_ONE, :USE_MODE_ALL
17
33
 
18
- attr_writer :logger, :extractors, :injectors, :error_handler,
19
- :id_generator
34
+ attr_writer :propagators, :error_handler, :id_generator
20
35
 
21
36
  def initialize
22
37
  @instrumentation_names = []
23
38
  @instrumentation_config_map = {}
24
- @injectors = nil
25
- @extractors = nil
39
+ @propagators = nil
26
40
  @span_processors = []
27
41
  @use_mode = USE_MODE_UNSPECIFIED
28
42
  @resource = Resources::Resource.default
@@ -33,6 +47,15 @@ module OpenTelemetry
33
47
  @logger ||= OpenTelemetry.logger
34
48
  end
35
49
 
50
+ # Accepts a logger and wraps it in the {ForwardingLogger} which allows
51
+ # for controlling the severity level emitted by the OpenTelemetry.logger
52
+ # independently of the supplied logger.
53
+ #
54
+ # @param [Logger] new_logger The logger for OpenTelemetry to use
55
+ def logger=(new_logger)
56
+ @logger = ForwardingLogger.new(new_logger, level: ENV['OTEL_LOG_LEVEL'] || Logger::INFO)
57
+ end
58
+
36
59
  def error_handler
37
60
  @error_handler ||= OpenTelemetry.error_handler
38
61
  end
@@ -53,7 +76,7 @@ module OpenTelemetry
53
76
  # @param [String] service_name The value to be used as the service name
54
77
  def service_name=(service_name)
55
78
  self.resource = OpenTelemetry::SDK::Resources::Resource.create(
56
- OpenTelemetry::SDK::Resources::Constants::SERVICE_RESOURCE[:name] => service_name
79
+ OpenTelemetry::SemanticConventions::Resource::SERVICE_NAME => service_name
57
80
  )
58
81
  end
59
82
 
@@ -63,7 +86,7 @@ module OpenTelemetry
63
86
  # @param [String] service_version The value to be used as the service version
64
87
  def service_version=(service_version)
65
88
  self.resource = OpenTelemetry::SDK::Resources::Resource.create(
66
- OpenTelemetry::SDK::Resources::Constants::SERVICE_RESOURCE[:version] => service_version
89
+ OpenTelemetry::SemanticConventions::Resource::SERVICE_VERSION => service_version
67
90
  )
68
91
  end
69
92
 
@@ -114,7 +137,6 @@ module OpenTelemetry
114
137
  def configure
115
138
  OpenTelemetry.logger = logger
116
139
  OpenTelemetry.error_handler = error_handler
117
- OpenTelemetry.baggage = Baggage::Manager.new
118
140
  configure_propagation
119
141
  configure_span_processors
120
142
  tracer_provider.id_generator = @id_generator
@@ -125,7 +147,7 @@ module OpenTelemetry
125
147
  private
126
148
 
127
149
  def tracer_provider
128
- @tracer_provider ||= Trace::TracerProvider.new(@resource)
150
+ @tracer_provider ||= Trace::TracerProvider.new(resource: @resource)
129
151
  end
130
152
 
131
153
  def check_use_mode!(mode)
@@ -136,39 +158,38 @@ module OpenTelemetry
136
158
  def install_instrumentation
137
159
  case @use_mode
138
160
  when USE_MODE_ONE
139
- OpenTelemetry.instrumentation_registry.install(@instrumentation_names, @instrumentation_config_map)
161
+ OpenTelemetry::Instrumentation.registry.install(@instrumentation_names, @instrumentation_config_map)
140
162
  when USE_MODE_ALL
141
- OpenTelemetry.instrumentation_registry.install_all(@instrumentation_config_map)
163
+ OpenTelemetry::Instrumentation.registry.install_all(@instrumentation_config_map)
142
164
  end
143
165
  end
144
166
 
145
167
  def configure_span_processors
146
- processors = @span_processors.empty? ? [wrapped_exporter_from_env].compact : @span_processors
168
+ processors = @span_processors.empty? ? wrapped_exporters_from_env.compact : @span_processors
147
169
  processors.each { |p| tracer_provider.add_span_processor(p) }
148
170
  end
149
171
 
150
- def wrapped_exporter_from_env
151
- exporter = ENV.fetch('OTEL_TRACES_EXPORTER', 'otlp')
152
- case exporter
153
- when 'none' then nil
154
- when 'otlp' then fetch_exporter(exporter, 'OpenTelemetry::Exporter::OTLP::Exporter')
155
- when 'jaeger' then fetch_exporter(exporter, 'OpenTelemetry::Exporter::Jaeger::CollectorExporter')
156
- when 'zipkin' then fetch_exporter(exporter, 'OpenTelemetry::Exporter::Zipkin::Exporter')
157
- when 'console' then Trace::Export::SimpleSpanProcessor.new(Trace::Export::ConsoleSpanExporter.new)
158
- else
159
- OpenTelemetry.logger.warn "The #{exporter} exporter is unknown and cannot be configured, spans will not be exported"
160
- nil
172
+ def wrapped_exporters_from_env
173
+ exporters = ENV.fetch('OTEL_TRACES_EXPORTER', 'otlp')
174
+ exporters.split(',').map do |exporter|
175
+ case exporter.strip
176
+ when 'none' then nil
177
+ when 'otlp' then fetch_exporter(exporter, 'OpenTelemetry::Exporter::OTLP::Exporter')
178
+ when 'jaeger' then fetch_exporter(exporter, 'OpenTelemetry::Exporter::Jaeger::CollectorExporter')
179
+ when 'zipkin' then fetch_exporter(exporter, 'OpenTelemetry::Exporter::Zipkin::Exporter')
180
+ when 'console' then Trace::Export::SimpleSpanProcessor.new(Trace::Export::ConsoleSpanExporter.new)
181
+ else
182
+ OpenTelemetry.logger.warn "The #{exporter} exporter is unknown and cannot be configured, spans will not be exported"
183
+ nil
184
+ end
161
185
  end
162
186
  end
163
187
 
164
- def configure_propagation # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
165
- propagators = ENV.fetch('OTEL_PROPAGATORS', 'tracecontext,baggage').split(',')
166
- injectors, extractors = propagators.uniq.collect do |propagator|
188
+ def configure_propagation # rubocop:disable Metrics/CyclomaticComplexity
189
+ propagators = ENV.fetch('OTEL_PROPAGATORS', 'tracecontext,baggage').split(',').uniq.collect do |propagator|
167
190
  case propagator
168
- when 'tracecontext'
169
- [OpenTelemetry::Trace::Propagation::TraceContext.text_map_injector, OpenTelemetry::Trace::Propagation::TraceContext.text_map_extractor]
170
- when 'baggage'
171
- [OpenTelemetry::Baggage::Propagation.text_map_injector, OpenTelemetry::Baggage::Propagation.text_map_extractor]
191
+ when 'tracecontext' then OpenTelemetry::Trace::Propagation::TraceContext.text_map_propagator
192
+ when 'baggage' then OpenTelemetry::Baggage::Propagation.text_map_propagator
172
193
  when 'b3' then fetch_propagator(propagator, 'OpenTelemetry::Propagator::B3::Single')
173
194
  when 'b3multi' then fetch_propagator(propagator, 'OpenTelemetry::Propagator::B3::Multi', 'b3')
174
195
  when 'jaeger' then fetch_propagator(propagator, 'OpenTelemetry::Propagator::Jaeger')
@@ -176,27 +197,17 @@ module OpenTelemetry
176
197
  when 'ottrace' then fetch_propagator(propagator, 'OpenTelemetry::Propagator::OTTrace')
177
198
  else
178
199
  OpenTelemetry.logger.warn "The #{propagator} propagator is unknown and cannot be configured"
179
- [Context::Propagation::NoopInjector.new, Context::Propagation::NoopExtractor.new]
200
+ NoopTextMapPropagator.new
180
201
  end
181
- end.transpose
182
- OpenTelemetry.propagation = create_propagator(@injectors || injectors.compact,
183
- @extractors || extractors.compact)
184
- end
185
-
186
- def create_propagator(injectors, extractors)
187
- if injectors.size > 1 || extractors.size > 1
188
- Context::Propagation::CompositePropagator.new(injectors, extractors)
189
- else
190
- Context::Propagation::Propagator.new(injectors.first, extractors.first)
191
202
  end
203
+ OpenTelemetry.propagation = Context::Propagation::CompositeTextMapPropagator.compose_propagators((@propagators || propagators).compact)
192
204
  end
193
205
 
194
206
  def fetch_propagator(name, class_name, gem_suffix = name)
195
- propagator_class = Kernel.const_get(class_name)
196
- [propagator_class.text_map_injector, propagator_class.text_map_extractor]
207
+ Kernel.const_get(class_name).text_map_propagator
197
208
  rescue NameError
198
209
  OpenTelemetry.logger.warn "The #{name} propagator cannot be configured - please add opentelemetry-propagator-#{gem_suffix} to your Gemfile"
199
- [nil, nil]
210
+ nil
200
211
  end
201
212
 
202
213
  def fetch_exporter(name, class_name)