Skip to content

Commit

Permalink
fix(blinker): Always set 500 on exception signal
Browse files Browse the repository at this point in the history
Signed-off-by: Ferenc Géczi <[email protected]>
  • Loading branch information
Ferenc- committed May 16, 2023
1 parent f283a4b commit 5525533
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 6 additions & 0 deletions instana/instrumentation/flask/with_blinker.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ def log_exception_with_instana(sender, exception, **extra):
scope = flask.g.scope
if scope.span is not None:
scope.span.log_exception(exception)
# As of Flask 2.3.x:
# https://github.com/pallets/flask/blob/
# d0bf462866289ad8bfe29b6e4e1e0f531003ab34/src/flask/app.py#L1379
# The `got_request_exception` signal, is only sent by
# the `handle_exception` method which "always causes a 500"
scope.span.set_tag(ext.HTTP_STATUS_CODE, 500)
scope.close()


Expand Down
3 changes: 1 addition & 2 deletions tests/clients/test_urllib3.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,7 @@ def test_exception_logging(self):
self.assertEqual('127.0.0.1:' + str(testenv["wsgi_port"]), wsgi_span.data["http"]["host"])
self.assertEqual('/exception', wsgi_span.data["http"]["url"])
self.assertEqual('GET', wsgi_span.data["http"]["method"])
# TODO: Investigate the missing status code in a separate commit
#self.assertEqual(500, wsgi_span.data["http"]["status"])
self.assertEqual(500, wsgi_span.data["http"]["status"])
if with_blinker:
self.assertEqual('fake error', wsgi_span.data["http"]["error"])
else:
Expand Down

0 comments on commit 5525533

Please sign in to comment.