lib/opentelemetry/sdk/configurator.rb in opentelemetry-sdk-1.0.0.rc1 vs lib/opentelemetry/sdk/configurator.rb in opentelemetry-sdk-1.0.0.rc2

- old
+ new

@@ -13,11 +13,11 @@ USE_MODE_ONE = 1 USE_MODE_ALL = 2 private_constant :USE_MODE_UNSPECIFIED, :USE_MODE_ONE, :USE_MODE_ALL - attr_writer :logger, :propagators, :error_handler, :id_generator + attr_writer :propagators, :error_handler, :id_generator def initialize @instrumentation_names = [] @instrumentation_config_map = {} @propagators = nil @@ -29,10 +29,19 @@ def logger @logger ||= OpenTelemetry.logger end + # Accepts a logger and wraps it in the {ForwardingLogger} which allows + # for controlling the severity level emitted by the OpenTelemetry.logger + # independently of the supplied logger. + # + # @param [Logger] new_logger The logger for OpenTelemetry to use + def logger=(new_logger) + @logger = ForwardingLogger.new(new_logger, level: ENV['OTEL_LOG_LEVEL'] || Logger::INFO) + end + def error_handler @error_handler ||= OpenTelemetry.error_handler end # Accepts a resource object that is merged with the default telemetry sdk @@ -110,21 +119,20 @@ # - setup tracer_provider and meter_provider # - install instrumentation def configure OpenTelemetry.logger = logger OpenTelemetry.error_handler = error_handler - OpenTelemetry.baggage = Baggage::Manager.new configure_propagation configure_span_processors tracer_provider.id_generator = @id_generator OpenTelemetry.tracer_provider = tracer_provider install_instrumentation end private def tracer_provider - @tracer_provider ||= Trace::TracerProvider.new(@resource) + @tracer_provider ||= Trace::TracerProvider.new(resource: @resource) end def check_use_mode!(mode) @use_mode = mode if @use_mode == USE_MODE_UNSPECIFIED raise 'Use either `use_all` or `use`, but not both' unless @use_mode == mode