lib/datadog/tracing/contrib/httprb/instrumentation.rb in ddtrace-1.8.0 vs lib/datadog/tracing/contrib/httprb/instrumentation.rb in ddtrace-1.9.0

- old
+ new

@@ -40,11 +40,11 @@ ensure res = super(req, options) end # Add additional response specific tags to the span. - annotate_span_with_response!(span, res) + annotate_span_with_response!(span, res, request_options) res end end @@ -79,16 +79,15 @@ span.set_tag(Tracing::Metadata::Ext::TAG_PEER_SERVICE, span.service) set_analytics_sample_rate(span, req_options) end - def annotate_span_with_response!(span, response) + def annotate_span_with_response!(span, response, request_options) return unless response && response.code span.set_tag(Tracing::Metadata::Ext::HTTP::TAG_STATUS_CODE, response.code) - case response.code.to_i - when 400...599 + if request_options[:error_status_codes].include? response.code.to_i # https://github.com/DataDog/dd-trace-rb/issues/1116 # parsing the response body message will alter downstream application behavior span.set_error(["Error #{response.code}", 'Error']) end end