Skip to content

Commit 5525533

Browse files
committed
fix(blinker): Always set 500 on exception signal
Signed-off-by: Ferenc Géczi <[email protected]>
1 parent f283a4b commit 5525533

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

instana/instrumentation/flask/with_blinker.py

+6
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ def log_exception_with_instana(sender, exception, **extra):
8282
scope = flask.g.scope
8383
if scope.span is not None:
8484
scope.span.log_exception(exception)
85+
# As of Flask 2.3.x:
86+
# https://github.com/pallets/flask/blob/
87+
# d0bf462866289ad8bfe29b6e4e1e0f531003ab34/src/flask/app.py#L1379
88+
# The `got_request_exception` signal, is only sent by
89+
# the `handle_exception` method which "always causes a 500"
90+
scope.span.set_tag(ext.HTTP_STATUS_CODE, 500)
8591
scope.close()
8692

8793

tests/clients/test_urllib3.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -501,8 +501,7 @@ def test_exception_logging(self):
501501
self.assertEqual('127.0.0.1:' + str(testenv["wsgi_port"]), wsgi_span.data["http"]["host"])
502502
self.assertEqual('/exception', wsgi_span.data["http"]["url"])
503503
self.assertEqual('GET', wsgi_span.data["http"]["method"])
504-
# TODO: Investigate the missing status code in a separate commit
505-
#self.assertEqual(500, wsgi_span.data["http"]["status"])
504+
self.assertEqual(500, wsgi_span.data["http"]["status"])
506505
if with_blinker:
507506
self.assertEqual('fake error', wsgi_span.data["http"]["error"])
508507
else:

0 commit comments

Comments
 (0)