lib/opentelemetry/instrumentation/rack/middlewares/event_handler.rb in opentelemetry-instrumentation-rack-0.24.6 vs lib/opentelemetry/instrumentation/rack/middlewares/event_handler.rb in opentelemetry-instrumentation-rack-0.25.0

- old
+ new

@@ -41,11 +41,10 @@ # @see OpenTelemetry::Instrumentation::Rack.current_span class EventHandler include ::Rack::Events::Abstract OTEL_TOKEN_AND_SPAN = 'otel.rack.token_and_span' - GOOD_HTTP_STATUSES = (100..499) # Creates a server span for this current request using the incoming parent context # and registers them as the {current_span} # # @param [Rack::Request] The current HTTP request @@ -206,10 +205,10 @@ rescue StandardError => e OpenTelemetry.handle_error(exception: e) end def add_response_attributes(span, response) - span.status = OpenTelemetry::Trace::Status.error unless GOOD_HTTP_STATUSES.include?(response.status.to_i) + span.status = OpenTelemetry::Trace::Status.error if response.server_error? attributes = extract_response_attributes(response) span.add_attributes(attributes) rescue StandardError => e OpenTelemetry.handle_error(exception: e) end