lib/opentelemetry/instrumentation/http_client/patches/client.rb in opentelemetry-instrumentation-http_client-0.22.7 vs lib/opentelemetry/instrumentation/http_client/patches/client.rb in opentelemetry-instrumentation-http_client-0.22.8
- old
+ new
@@ -8,10 +8,13 @@
module Instrumentation
module HttpClient
module Patches
# Module to prepend to HTTPClient for instrumentation
module Client
+ # Constant for the HTTP status range
+ HTTP_STATUS_SUCCESS_RANGE = (100..399)
+
private
def do_get_block(req, proxy, conn, &block)
uri = req.header.request_uri
url = "#{uri.scheme}://#{uri.host}"
@@ -40,10 +43,10 @@
return unless response&.status_code
status_code = response.status_code.to_i
span.set_attribute('http.status_code', status_code)
- span.status = OpenTelemetry::Trace::Status.error unless (100..399).cover?(status_code.to_i)
+ span.status = OpenTelemetry::Trace::Status.error unless HTTP_STATUS_SUCCESS_RANGE.cover?(status_code)
end
def tracer
HttpClient::Instrumentation.instance.tracer
end