Skip to content

Commit 97965e0

Browse files
bbelyeubbelyeu
andauthored
Catch valid AIOHTTP Exception responses (#256)
so they are not input as errors Co-authored-by: bbelyeu <[email protected]>
1 parent 6b23dc2 commit 97965e0

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

instana/instrumentation/aiohttp/server.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,13 @@ async def stan_middleware(request, handler):
3737
if custom_header in request.headers:
3838
scope.span.set_tag("http.%s" % custom_header, request.headers[custom_header])
3939

40-
response = await handler(request)
40+
response = None
41+
try:
42+
response = await handler(request)
43+
except aiohttp.web.HTTPException as e:
44+
# AIOHTTP uses exceptions for specific responses
45+
# see https://docs.aiohttp.org/en/latest/web_exceptions.html#web-server-exceptions
46+
response = e
4147

4248
if response is not None:
4349
# Mark 500 responses as errored

0 commit comments

Comments
 (0)