lib/opentelemetry/sdk.rb in opentelemetry-sdk-0.11.1 vs lib/opentelemetry/sdk.rb in opentelemetry-sdk-0.12.0

- old
+ new

@@ -16,10 +16,15 @@ module OpenTelemetry # SDK provides the reference implementation of the OpenTelemetry API. module SDK extend self + # ConfigurationError is an exception type used to wrap configuration errors + # passed to OpenTelemetry.error_handler. This can be used to distinguish + # errors reported during SDK configuration. + ConfigurationError = Class.new(OpenTelemetry::Error) + # Configures SDK and instrumentation # # @yieldparam [Configurator] configurator Yields a configurator to the # provided block # @@ -55,9 +60,15 @@ # end def configure configurator = Configurator.new yield configurator if block_given? configurator.configure + rescue StandardError + begin + raise ConfigurationError + rescue ConfigurationError => e + OpenTelemetry.handle_error(exception: e, message: 'unexpected configuration error') + end end end end require 'opentelemetry/sdk/configurator'