opentelemetry-sdk 0.14.0 → 0.15.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: 86e11789326f901d3c6e768ea1eac43f49826fd762a74e1878adaaf76d398074
4
- data.tar.gz: 9431b37ace4dc00894f8aa81d89522d139120958a680141fe605a5ff73e57a66
3
+ metadata.gz: 83141347c526da6e87b4858c6ad9277ec4d2a59a452944114f21618b86d98db1
4
+ data.tar.gz: e1ebac32ea8dbcbb5087bf2d06bae25f5ed269fb7a3e17159d37d41def7b5063
5
5
  SHA512:
6
- metadata.gz: 6292a201663ec6e5a7cd54560ef25855865bc77b698fd4c80a1ee4bc4109760da9f9f3e2522753c0bcc6edd11728e0222093e3759db4466b12a423544f64358a
7
- data.tar.gz: 602740b9c995cc0b204b45c2923914e57ddeaa5ba809d06e1b6707c2340597a53a33d9311e349ea2ece7b7c45181ecdf4a8b2e33511aab70a08cb081f2d9b30e
6
+ metadata.gz: 68a19f8ce70e8a1dc00bcea801c16f405f86a826e9501a9e513fd0070adca7e8cbe51f958f6957f8d38bae768fa9f8b4b111c55112d95309bb0bcfb8b85c5e26
7
+ data.tar.gz: a25e070825c5d2f886e01c8b1659e63f73810fbae89ac629c4e5b2319391c859db90b87901d294044fc06e8f4bb7879e97ce3549484d408695f7aac0345c1256
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Release History: opentelemetry-sdk
2
2
 
3
+ ### v0.15.0 / 2021-02-18
4
+
5
+ * BREAKING CHANGE: Streamline processor pipeline
6
+
7
+ * ADDED: Add instrumentation config validation
8
+ * FIXED: Streamline processor pipeline
9
+ * FIXED: OTEL_TRACE -> OTEL_TRACES env vars
10
+ * FIXED: Change limits from 1000 to 128
11
+ * FIXED: OTEL_TRACES_EXPORTER and OTEL_PROPAGATORS
12
+ * FIXED: Add thread error handling to the BSP
13
+ * DOCS: Clarify nil attribute values not allowed
14
+
3
15
  ### v0.14.0 / 2021-02-03
4
16
 
5
17
  * BREAKING CHANGE: Replace getter and setter callables and remove rack specific propagators
@@ -143,41 +143,66 @@ module OpenTelemetry
143
143
  end
144
144
 
145
145
  def configure_span_processors
146
- processors = @span_processors.empty? ? [default_span_processor] : @span_processors
146
+ processors = @span_processors.empty? ? [wrapped_exporter_from_env].compact : @span_processors
147
147
  processors.each { |p| tracer_provider.add_span_processor(p) }
148
148
  end
149
149
 
150
- def default_span_processor
151
- Trace::Export::SimpleSpanProcessor.new(
152
- Trace::Export::ConsoleSpanExporter.new
153
- )
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
+ else
158
+ OpenTelemetry.logger.warn "The #{exporter} exporter is unknown and cannot be configured, spans will not be exported"
159
+ nil
160
+ end
154
161
  end
155
162
 
156
- def configure_propagation
157
- OpenTelemetry.propagation = create_propagator(@injectors || default_injectors,
158
- @extractors || default_extractors)
163
+ def configure_propagation # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
164
+ propagators = ENV.fetch('OTEL_PROPAGATORS', 'tracecontext,baggage').split(',')
165
+ injectors, extractors = propagators.uniq.collect do |propagator|
166
+ case propagator
167
+ when 'tracecontext'
168
+ [OpenTelemetry::Trace::Propagation::TraceContext.text_map_injector, OpenTelemetry::Trace::Propagation::TraceContext.text_map_extractor]
169
+ when 'baggage'
170
+ [OpenTelemetry::Baggage::Propagation.text_map_injector, OpenTelemetry::Baggage::Propagation.text_map_extractor]
171
+ when 'b3' then fetch_propagator(propagator, 'OpenTelemetry::Propagator::B3::Single')
172
+ when 'b3multi' then fetch_propagator(propagator, 'OpenTelemetry::Propagator::B3::Multi', 'b3')
173
+ when 'jaeger' then fetch_propagator(propagator, 'OpenTelemetry::Propagator::Jaeger')
174
+ when 'xray' then fetch_propagator(propagator, 'OpenTelemetry::Propagator::XRay')
175
+ when 'ottrace' then fetch_propagator(propagator, 'OpenTelemetry::Propagator::OTTrace')
176
+ else
177
+ OpenTelemetry.logger.warn "The #{propagator} propagator is unknown and cannot be configured"
178
+ [Context::Propagation::NoopInjector.new, Context::Propagation::NoopExtractor.new]
179
+ end
180
+ end.transpose
181
+ OpenTelemetry.propagation = create_propagator(@injectors || injectors.compact,
182
+ @extractors || extractors.compact)
159
183
  end
160
184
 
161
185
  def create_propagator(injectors, extractors)
162
186
  if injectors.size > 1 || extractors.size > 1
163
187
  Context::Propagation::CompositePropagator.new(injectors, extractors)
164
188
  else
165
- Context::Propagation::Propagator.new(injectors, extractors)
189
+ Context::Propagation::Propagator.new(injectors.first, extractors.first)
166
190
  end
167
191
  end
168
192
 
169
- def default_injectors
170
- [
171
- OpenTelemetry::Trace::Propagation::TraceContext.text_map_injector,
172
- OpenTelemetry::Baggage::Propagation.text_map_injector
173
- ]
193
+ def fetch_propagator(name, class_name, gem_suffix = name)
194
+ propagator_class = Kernel.const_get(class_name)
195
+ [propagator_class.text_map_injector, propagator_class.text_map_extractor]
196
+ rescue NameError
197
+ OpenTelemetry.logger.warn "The #{name} propagator cannot be configured - please add opentelemetry-propagator-#{gem_suffix} to your Gemfile"
198
+ [nil, nil]
174
199
  end
175
200
 
176
- def default_extractors
177
- [
178
- OpenTelemetry::Trace::Propagation::TraceContext.text_map_extractor,
179
- OpenTelemetry::Baggage::Propagation.text_map_extractor
180
- ]
201
+ def fetch_exporter(name, class_name)
202
+ Trace::Export::BatchSpanProcessor.new(Kernel.const_get(class_name).new)
203
+ rescue NameError
204
+ OpenTelemetry.logger.warn "The #{name} exporter cannot be configured - please add opentelemetry-exporter-#{name} to your Gemfile, spans will not be exported"
205
+ nil
181
206
  end
182
207
  end
183
208
  end
@@ -33,9 +33,9 @@ module OpenTelemetry
33
33
  # @return [TraceConfig] with the desired values.
34
34
  # @raise [ArgumentError] if any of the max numbers are not positive.
35
35
  def initialize(sampler: sampler_from_environment(Samplers.parent_based(root: Samplers::ALWAYS_ON)),
36
- max_attributes_count: Integer(ENV.fetch('OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT', 1000)),
37
- max_events_count: Integer(ENV.fetch('OTEL_SPAN_EVENT_COUNT_LIMIT', 1000)),
38
- max_links_count: Integer(ENV.fetch('OTEL_SPAN_LINK_COUNT_LIMIT', 1000)),
36
+ max_attributes_count: Integer(ENV.fetch('OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT', 128)),
37
+ max_events_count: Integer(ENV.fetch('OTEL_SPAN_EVENT_COUNT_LIMIT', 128)),
38
+ max_links_count: Integer(ENV.fetch('OTEL_SPAN_LINK_COUNT_LIMIT', 128)),
39
39
  max_attributes_per_event: max_attributes_count,
40
40
  max_attributes_per_link: max_attributes_count)
41
41
  raise ArgumentError, 'max_attributes_count must be positive' unless max_attributes_count.positive?
@@ -56,13 +56,13 @@ module OpenTelemetry
56
56
  private
57
57
 
58
58
  def sampler_from_environment(default_sampler) # rubocop:disable Metrics/CyclomaticComplexity
59
- case ENV['OTEL_TRACE_SAMPLER']
59
+ case ENV['OTEL_TRACES_SAMPLER']
60
60
  when 'always_on' then Samplers::ALWAYS_ON
61
61
  when 'always_off' then Samplers::ALWAYS_OFF
62
- when 'traceidratio' then Samplers.trace_id_ratio_based(Float(ENV.fetch('OTEL_TRACE_SAMPLER_ARG', 1.0)))
62
+ when 'traceidratio' then Samplers.trace_id_ratio_based(Float(ENV.fetch('OTEL_TRACES_SAMPLER_ARG', 1.0)))
63
63
  when 'parentbased_always_on' then Samplers.parent_based(root: Samplers::ALWAYS_ON)
64
64
  when 'parentbased_always_off' then Samplers.parent_based(root: Samplers::ALWAYS_OFF)
65
- when 'parentbased_traceidratio' then Samplers.parent_based(root: Samplers.trace_id_ratio_based(Float(ENV.fetch('OTEL_TRACE_SAMPLER_ARG', 1.0))))
65
+ when 'parentbased_traceidratio' then Samplers.parent_based(root: Samplers.trace_id_ratio_based(Float(ENV.fetch('OTEL_TRACES_SAMPLER_ARG', 1.0))))
66
66
  else default_sampler
67
67
  end
68
68
  rescue StandardError => e
@@ -28,7 +28,8 @@ module OpenTelemetry
28
28
  class BatchSpanProcessor # rubocop:disable Metrics/ClassLength
29
29
  # Returns a new instance of the {BatchSpanProcessor}.
30
30
  #
31
- # @param [SpanExporter] exporter
31
+ # @param [SpanExporter] exporter the (duck type) SpanExporter to where the
32
+ # recorded Spans are pushed after batching.
32
33
  # @param [Numeric] exporter_timeout the delay interval between two
33
34
  # consecutive exports. Defaults to the value of the OTEL_BSP_EXPORT_TIMEOUT
34
35
  # environment variable, if set, or 30,000 (30 seconds).
@@ -43,7 +44,7 @@ module OpenTelemetry
43
44
  # variable, if set, or 512.
44
45
  #
45
46
  # @return a new instance of the {BatchSpanProcessor}.
46
- def initialize(exporter:,
47
+ def initialize(exporter,
47
48
  exporter_timeout: Float(ENV.fetch('OTEL_BSP_EXPORT_TIMEOUT', 30_000)),
48
49
  schedule_delay: Float(ENV.fetch('OTEL_BSP_SCHEDULE_DELAY', 5_000)),
49
50
  max_queue_size: Integer(ENV.fetch('OTEL_BSP_MAX_QUEUE_SIZE', 2048)),
@@ -176,6 +177,9 @@ module OpenTelemetry
176
177
  @pid = pid
177
178
  spans.clear
178
179
  @thread = restart_thread ? Thread.new { work } : nil
180
+ rescue ThreadError => e
181
+ @metrics_reporter.add_to_counter('otel.bsp.error', labels: { 'reason' => 'ThreadError' })
182
+ OpenTelemetry.handle_error(exception: e, message: 'unexpected error in BatchSpanProcessor#reset_on_fork')
179
183
  end
180
184
 
181
185
  def export_batch(batch, timeout: @exporter_timeout_seconds)
@@ -64,6 +64,9 @@ module OpenTelemetry
64
64
  #
65
65
  # @param [String] key
66
66
  # @param [String, Boolean, Numeric, Array<String, Numeric, Boolean>] value
67
+ # Values must be non-nil and (array of) string, boolean or numeric type.
68
+ # Array values must not contain nil elements and all elements must be of
69
+ # the same basic type (string, numeric, boolean).
67
70
  #
68
71
  # @return [self] returns itself
69
72
  def set_attribute(key, value)
@@ -96,7 +99,7 @@ module OpenTelemetry
96
99
  # @param [String] name Name of the event.
97
100
  # @param [optional Hash{String => String, Numeric, Boolean, Array<String, Numeric, Boolean>}] attributes
98
101
  # One or more key:value pairs, where the keys must be strings and the
99
- # values may be string, boolean or numeric type.
102
+ # values may be (array of) string, boolean or numeric type.
100
103
  # @param [optional Time] timestamp Optional timestamp for the event.
101
104
  #
102
105
  # @return [self] returns itself
@@ -65,11 +65,6 @@ module OpenTelemetry
65
65
 
66
66
  # Adds a new SpanProcessor to this {Tracer}.
67
67
  #
68
- # Any registered processor causes overhead, consider to use an
69
- # async/batch processor especially for span exporting, and export to
70
- # multiple backends using the
71
- # {io.opentelemetry.sdk.trace.export.MultiSpanExporter}.
72
- #
73
68
  # @param span_processor the new SpanProcessor to be added.
74
69
  def add_span_processor(span_processor)
75
70
  @mutex.synchronize do
@@ -78,7 +73,11 @@ module OpenTelemetry
78
73
  return
79
74
  end
80
75
  @registered_span_processors << span_processor
81
- @active_span_processor = MultiSpanProcessor.new(@registered_span_processors.dup)
76
+ @active_span_processor = if @registered_span_processors.size == 1
77
+ span_processor
78
+ else
79
+ MultiSpanProcessor.new(@registered_span_processors.dup)
80
+ end
82
81
  end
83
82
  end
84
83
  end
@@ -7,6 +7,6 @@
7
7
  module OpenTelemetry
8
8
  module SDK
9
9
  ## Current OpenTelemetry version
10
- VERSION = '0.14.0'
10
+ VERSION = '0.15.0'
11
11
  end
12
12
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opentelemetry-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.0
4
+ version: 0.15.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: 2021-02-03 00:00:00.000000000 Z
11
+ date: 2021-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opentelemetry-api
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.14.0
19
+ version: 0.15.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.14.0
26
+ version: 0.15.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: opentelemetry-common
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.14.0
33
+ version: 0.15.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.14.0
40
+ version: 0.15.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '5.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: opentelemetry-exporter-jaeger
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.15.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.15.0
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: rake
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -201,10 +215,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby
201
215
  licenses:
202
216
  - Apache-2.0
203
217
  metadata:
204
- changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk/v0.14.0/file.CHANGELOG.html
218
+ changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk/v0.15.0/file.CHANGELOG.html
205
219
  source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/sdk
206
220
  bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby/issues
207
- documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk/v0.14.0
221
+ documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk/v0.15.0
208
222
  post_install_message:
209
223
  rdoc_options: []
210
224
  require_paths: