@@ -557,6 +557,50 @@ def zerodivision(e):
557
557
assert not events
558
558
559
559
560
+ def test_tracing_success (sentry_init , capture_events , app ):
561
+ sentry_init (traces_sample_rate = 1.0 , integrations = [flask_sentry .FlaskIntegration ()])
562
+
563
+ events = capture_events ()
564
+
565
+ with app .test_client () as client :
566
+ response = client .get ("/message" )
567
+ assert response .status_code == 200
568
+
569
+ message_event , transaction_event = events
570
+
571
+ assert transaction_event ["type" ] == "transaction"
572
+ assert transaction_event ["transaction" ] == "hi"
573
+ assert "status" not in transaction_event ["contexts" ]["trace" ]
574
+
575
+ assert message_event ["message" ] == "hi"
576
+ assert message_event ["transaction" ] == "hi"
577
+
578
+
579
+ def test_tracing_error (sentry_init , capture_events , app ):
580
+ sentry_init (traces_sample_rate = 1.0 , integrations = [flask_sentry .FlaskIntegration ()])
581
+
582
+ events = capture_events ()
583
+
584
+ @app .route ("/error" )
585
+ def error ():
586
+ 1 / 0
587
+
588
+ with pytest .raises (ZeroDivisionError ):
589
+ with app .test_client () as client :
590
+ response = client .get ("/error" )
591
+ assert response .status_code == 500
592
+
593
+ error_event , transaction_event = events
594
+
595
+ assert transaction_event ["type" ] == "transaction"
596
+ assert transaction_event ["transaction" ] == "error"
597
+ assert transaction_event ["contexts" ]["trace" ]["status" ] == "failure"
598
+
599
+ assert error_event ["transaction" ] == "error"
600
+ exception , = error_event ["exception" ]["values" ]
601
+ assert exception ["type" ] == "ZeroDivisionError"
602
+
603
+
560
604
def test_class_based_views (sentry_init , app , capture_events ):
561
605
sentry_init (integrations = [flask_sentry .FlaskIntegration ()])
562
606
events = capture_events ()
0 commit comments