lib/opentelemetry/sdk/configurator.rb in opentelemetry-sdk-0.16.0 vs lib/opentelemetry/sdk/configurator.rb in opentelemetry-sdk-0.17.0
- old
+ new
@@ -13,18 +13,16 @@
USE_MODE_ONE = 1
USE_MODE_ALL = 2
private_constant :USE_MODE_UNSPECIFIED, :USE_MODE_ONE, :USE_MODE_ALL
- attr_writer :logger, :extractors, :injectors, :error_handler,
- :id_generator
+ attr_writer :logger, :propagators, :error_handler, :id_generator
def initialize
@instrumentation_names = []
@instrumentation_config_map = {}
- @injectors = nil
- @extractors = nil
+ @propagators = nil
@span_processors = []
@use_mode = USE_MODE_UNSPECIFIED
@resource = Resources::Resource.default
@id_generator = OpenTelemetry::Trace
end
@@ -134,13 +132,13 @@
end
def install_instrumentation
case @use_mode
when USE_MODE_ONE
- OpenTelemetry.instrumentation_registry.install(@instrumentation_names, @instrumentation_config_map)
+ OpenTelemetry::Instrumentation.registry.install(@instrumentation_names, @instrumentation_config_map)
when USE_MODE_ALL
- OpenTelemetry.instrumentation_registry.install_all(@instrumentation_config_map)
+ OpenTelemetry::Instrumentation.registry.install_all(@instrumentation_config_map)
end
end
def configure_span_processors
processors = @span_processors.empty? ? [wrapped_exporter_from_env].compact : @span_processors
@@ -159,45 +157,32 @@
OpenTelemetry.logger.warn "The #{exporter} exporter is unknown and cannot be configured, spans will not be exported"
nil
end
end
- def configure_propagation # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
- propagators = ENV.fetch('OTEL_PROPAGATORS', 'tracecontext,baggage').split(',')
- injectors, extractors = propagators.uniq.collect do |propagator|
+ def configure_propagation # rubocop:disable Metrics/CyclomaticComplexity
+ propagators = ENV.fetch('OTEL_PROPAGATORS', 'tracecontext,baggage').split(',').uniq.collect do |propagator|
case propagator
- when 'tracecontext'
- [OpenTelemetry::Trace::Propagation::TraceContext.text_map_injector, OpenTelemetry::Trace::Propagation::TraceContext.text_map_extractor]
- when 'baggage'
- [OpenTelemetry::Baggage::Propagation.text_map_injector, OpenTelemetry::Baggage::Propagation.text_map_extractor]
+ when 'tracecontext' then OpenTelemetry::Trace::Propagation::TraceContext.text_map_propagator
+ when 'baggage' then OpenTelemetry::Baggage::Propagation.text_map_propagator
when 'b3' then fetch_propagator(propagator, 'OpenTelemetry::Propagator::B3::Single')
when 'b3multi' then fetch_propagator(propagator, 'OpenTelemetry::Propagator::B3::Multi', 'b3')
when 'jaeger' then fetch_propagator(propagator, 'OpenTelemetry::Propagator::Jaeger')
when 'xray' then fetch_propagator(propagator, 'OpenTelemetry::Propagator::XRay')
when 'ottrace' then fetch_propagator(propagator, 'OpenTelemetry::Propagator::OTTrace')
else
OpenTelemetry.logger.warn "The #{propagator} propagator is unknown and cannot be configured"
- [Context::Propagation::NoopInjector.new, Context::Propagation::NoopExtractor.new]
+ Context::Propagation::NoopTextMapPropagator.new
end
- end.transpose
- OpenTelemetry.propagation = create_propagator(@injectors || injectors.compact,
- @extractors || extractors.compact)
- end
-
- def create_propagator(injectors, extractors)
- if injectors.size > 1 || extractors.size > 1
- Context::Propagation::CompositePropagator.new(injectors, extractors)
- else
- Context::Propagation::Propagator.new(injectors.first, extractors.first)
end
+ OpenTelemetry.propagation = Context::Propagation::CompositeTextMapPropagator.compose_propagators((@propagators || propagators).compact)
end
def fetch_propagator(name, class_name, gem_suffix = name)
- propagator_class = Kernel.const_get(class_name)
- [propagator_class.text_map_injector, propagator_class.text_map_extractor]
+ Kernel.const_get(class_name).text_map_propagator
rescue NameError
OpenTelemetry.logger.warn "The #{name} propagator cannot be configured - please add opentelemetry-propagator-#{gem_suffix} to your Gemfile"
- [nil, nil]
+ nil
end
def fetch_exporter(name, class_name)
Trace::Export::BatchSpanProcessor.new(Kernel.const_get(class_name).new)
rescue NameError