File tree Expand file tree Collapse file tree 1 file changed +6
-13
lines changed
instrumentation/httpx/lib/opentelemetry/instrumentation/httpx Expand file tree Collapse file tree 1 file changed +6
-13
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments