lib/httpx/adapters/datadog.rb in httpx-0.24.6 vs lib/httpx/adapters/datadog.rb in httpx-0.24.7

- old
+ new

@@ -186,23 +186,43 @@ option :service_name, default: "httpx" option :distributed_tracing, default: true option :split_by_domain, default: false - option :enabled do |o| - o.default { env_to_bool("DD_TRACE_HTTPX_ENABLED", true) } - o.lazy - end + if DDTrace::VERSION::STRING >= "1.13.0" + option :enabled do |o| + o.type :bool + o.env "DD_TRACE_HTTPX_ENABLED" + o.default true + end - option :analytics_enabled do |o| - o.default { env_to_bool(%w[DD_TRACE_HTTPX_ANALYTICS_ENABLED DD_HTTPX_ANALYTICS_ENABLED], false) } - o.lazy - end + option :analytics_enabled do |o| + o.type :bool + o.env "DD_TRACE_HTTPX_ANALYTICS_ENABLED" + o.default false + end - option :analytics_sample_rate do |o| - o.default { env_to_float(%w[DD_TRACE_HTTPX_ANALYTICS_SAMPLE_RATE DD_HTTPX_ANALYTICS_SAMPLE_RATE], 1.0) } - o.lazy + option :analytics_sample_rate do |o| + o.type :float + o.env "DD_TRACE_HTTPX_ANALYTICS_SAMPLE_RATE" + o.default 1.0 + end + else + option :enabled do |o| + o.default { env_to_bool("DD_TRACE_HTTPX_ENABLED", true) } + o.lazy + end + + option :analytics_enabled do |o| + o.default { env_to_bool(%w[DD_TRACE_HTTPX_ANALYTICS_ENABLED DD_HTTPX_ANALYTICS_ENABLED], false) } + o.lazy + end + + option :analytics_sample_rate do |o| + o.default { env_to_float(%w[DD_TRACE_HTTPX_ANALYTICS_SAMPLE_RATE DD_HTTPX_ANALYTICS_SAMPLE_RATE], 1.0) } + o.lazy + end end if defined?(TRACING_MODULE::Contrib::SpanAttributeSchema) option :service_name do |o| o.default do @@ -222,10 +242,22 @@ end end option :distributed_tracing, default: true - option :error_handler, default: DEFAULT_ERROR_HANDLER + if DDTrace::VERSION::STRING >= "1.15.0" + option :error_handler do |o| + o.type :proc + o.default_proc(&DEFAULT_ERROR_HANDLER) + end + elsif DDTrace::VERSION::STRING >= "1.13.0" + option :error_handler do |o| + o.type :proc + o.experimental_default_proc(&DEFAULT_ERROR_HANDLER) + end + else + option :error_handler, default: DEFAULT_ERROR_HANDLER + end end end # Patcher enables patching of 'httpx' with datadog components. #