lib/httpx/adapters/datadog.rb in httpx-1.0.1 vs lib/httpx/adapters/datadog.rb in httpx-1.0.2
- old
+ new
@@ -124,23 +124,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?(Datadog::Tracing::Contrib::SpanAttributeSchema)
option :service_name do |o|
o.default do
@@ -160,10 +180,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.
#