Skip to content

Commit 8699f9c

Browse files
committed
Deal with an exception not setting the span's http status code.
1 parent e312bec commit 8699f9c

File tree

1 file changed

+6
-2
lines changed
  • instrumentation/opentelemetry-instrumentation-aiohttp-server/src/opentelemetry/instrumentation/aiohttp_server

1 file changed

+6
-2
lines changed

instrumentation/opentelemetry-instrumentation-aiohttp-server/src/opentelemetry/instrumentation/aiohttp_server/__init__.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,12 @@ async def middleware(request, handler):
150150
attributes = collect_request_attributes(request)
151151
attributes.update(additional_attributes)
152152
span.set_attributes(attributes)
153-
resp = await handler(request)
154-
set_status_code(span, resp.status)
153+
try:
154+
resp = await handler(request)
155+
set_status_code(span, resp.status)
156+
except web.HTTPException as ex:
157+
set_status_code(span, ex.status_code)
158+
raise
155159
return resp
156160

157161

0 commit comments

Comments
 (0)