Skip to content

Commit 339613a

Browse files
committed
Update plugin.rb
1 parent ca06278 commit 339613a

File tree

1 file changed

+6
-13
lines changed
  • instrumentation/httpx/lib/opentelemetry/instrumentation/httpx

1 file changed

+6
-13
lines changed

instrumentation/httpx/lib/opentelemetry/instrumentation/httpx/plugin.rb

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,12 @@ def call(request)
4949
end
5050

5151
def finish(response, span)
52-
if response.is_a?(::HTTPX::ErrorResponse)
53-
span.record_exception(response.error)
54-
span.status = Trace::Status.error(response.error.to_s)
55-
else
56-
span.set_attribute(OpenTelemetry::SemanticConventions::Trace::HTTP_STATUS_CODE, response.status)
57-
58-
if response.status >= 400 && response.status <= 599
59-
err = ::HTTPX::HTTPError.new(response)
60-
span.record_exception(err)
61-
span.status = Trace::Status.error(err.to_s)
62-
end
63-
end
64-
52+
span.set_attribute(OpenTelemetry::SemanticConventions::Trace::HTTP_STATUS_CODE, response.status)
53+
response.raise_for_status
54+
rescue HTTPX::HTTPError => err
55+
span.record_exception(err)
56+
span.status = Trace::Status.error(err.to_s)
57+
ensure
6558
span.finish
6659
end
6760

0 commit comments

Comments
 (0)