lib/opentelemetry/sdk/trace/config/trace_config.rb in opentelemetry-sdk-0.12.0 vs lib/opentelemetry/sdk/trace/config/trace_config.rb in opentelemetry-sdk-0.12.1
- old
+ new
@@ -57,13 +57,13 @@
def sampler_from_environment(default_sampler) # rubocop:disable Metrics/CyclomaticComplexity
case ENV['OTEL_TRACE_SAMPLER']
when 'always_on' then Samplers::ALWAYS_ON
when 'always_off' then Samplers::ALWAYS_OFF
- when 'traceidratio' then Samplers.trace_id_ratio_based(Float(ENV['OTEL_TRACE_SAMPLER_ARG']))
+ when 'traceidratio' then Samplers.trace_id_ratio_based(Float(ENV.fetch('OTEL_TRACE_SAMPLER_ARG', 1.0)))
when 'parentbased_always_on' then Samplers.parent_based(root: Samplers::ALWAYS_ON)
when 'parentbased_always_off' then Samplers.parent_based(root: Samplers::ALWAYS_OFF)
- when 'parentbased_traceidratio' then Samplers.parent_based(root: Samplers.trace_id_ratio_based(Float(ENV['OTEL_TRACE_SAMPLER_ARG'])))
+ when 'parentbased_traceidratio' then Samplers.parent_based(root: Samplers.trace_id_ratio_based(Float(ENV.fetch('OTEL_TRACE_SAMPLER_ARG', 1.0))))
else default_sampler
end
rescue StandardError => e
OpenTelemetry.handle_error(exception: e, message: "installing default sampler #{default_sampler.description}")
default_sampler