1515from flask .views import View
1616from flask_login import LoginManager , login_user
1717
18+ from sentry_sdk .traces import SpanStatus
19+
1820try :
1921 from werkzeug .wrappers .request import UnsupportedMediaType
2022except ImportError :
@@ -814,7 +816,7 @@ def hi_tx():
814816 span = spans [0 ].payload
815817 assert span ["is_segment" ] is True
816818 assert span ["name" ] == "hi_tx"
817- assert span ["status" ] == "ok"
819+ assert span ["status" ] == SpanStatus . OK
818820 assert span ["attributes" ]["sentry.op" ] == "http.server"
819821 assert span ["attributes" ]["sentry.origin" ] == "auto.http.flask"
820822
@@ -870,7 +872,7 @@ def error():
870872 span = spans [0 ].payload
871873 assert span ["is_segment" ] is True
872874 assert span ["name" ] == "error"
873- assert span ["status" ] == "error"
875+ assert span ["status" ] == SpanStatus . ERROR
874876 assert span ["attributes" ]["sentry.op" ] == "http.server"
875877 assert span ["attributes" ]["sentry.origin" ] == "auto.http.flask"
876878 assert len (error_events ) == 1
@@ -1011,6 +1013,7 @@ def test_response_status_code_ok(
10111013):
10121014 """
10131015 Tests that the response status code is added to the transaction/span.
1016+ This also works for when there is an Exception during the request, but somehow the test flask app doesn't seem to trigger that.
10141017 """
10151018 sentry_init (
10161019 integrations = [flask_sentry .FlaskIntegration ()],
@@ -1033,7 +1036,7 @@ def test_response_status_code_ok(
10331036 assert len (items ) == 1
10341037 span = items [0 ].payload
10351038 assert span ["attributes" ]["http.response.status_code" ] == 200
1036- assert span ["status" ] == "ok"
1039+ assert span ["status" ] == SpanStatus . OK
10371040 else :
10381041 (_ , transaction_envelope , _ ) = envelopes
10391042 transaction = transaction_envelope .get_transaction_event ()
@@ -1071,7 +1074,7 @@ def test_response_status_code_not_found(
10711074 assert len (items ) == 1
10721075 span = items [0 ].payload
10731076 assert span ["attributes" ]["http.response.status_code" ] == 404
1074- assert span ["status" ] == "error"
1077+ assert span ["status" ] == SpanStatus . ERROR
10751078 else :
10761079 (transaction_envelope , _ ) = envelopes
10771080 transaction = transaction_envelope .get_transaction_event ()
0 commit comments