@@ -355,7 +355,7 @@ def test_timeout_records_error(self) -> None:
355355 def test_connection_error_records_error (self ) -> None :
356356 responses .add (
357357 responses .GET ,
358- f"{ self .REGION .address } /connect-error" ,
358+ f"{ self .CELL .address } /connect-error" ,
359359 body = ConnectionError (),
360360 )
361361 with patch ("sentry.hybridcloud.apigateway.proxy.CircuitBreaker" ) as mock_breaker_class :
@@ -371,7 +371,7 @@ def test_connection_error_records_error(self) -> None:
371371 def test_connection_error_records_metric (self ) -> None :
372372 responses .add (
373373 responses .GET ,
374- f"{ self .REGION .address } /connect-error" ,
374+ f"{ self .CELL .address } /connect-error" ,
375375 body = ConnectionError (),
376376 )
377377 with patch ("sentry.hybridcloud.apigateway.proxy.metrics" ) as mock_metrics :
@@ -380,12 +380,30 @@ def test_connection_error_records_metric(self) -> None:
380380 proxy_request (request , self .organization .slug , url_name )
381381 mock_metrics .incr .assert_any_call (
382382 "apigateway.proxy.connection_error" ,
383- tags = {"region" : self .REGION .name , "url_name" : url_name },
383+ tags = {"region" : self .CELL .name , "url_name" : url_name },
384384 )
385385
386386 @responses .activate
387387 @override_options (CB_ENABLED )
388- def test_5xx_response_does_not_record_error (self ) -> None :
388+ def test_504_response_does_not_record_error (self ) -> None :
389+ responses .add (
390+ responses .GET ,
391+ f"{ self .CELL .address } /server-error" ,
392+ status = 504 ,
393+ body = json .dumps ({"detail" : "gateway timeout" }),
394+ content_type = "application/json" ,
395+ )
396+ with patch ("sentry.hybridcloud.apigateway.proxy.CircuitBreaker" ) as mock_breaker_class :
397+ mock_breaker = self ._make_breaker_mock (allow_request = True )
398+ mock_breaker_class .return_value = mock_breaker
399+ request = RequestFactory ().get ("http://sentry.io/server-error" )
400+ resp = proxy_request (request , self .organization .slug , url_name )
401+ assert resp .status_code == 504
402+ mock_breaker .record_error .assert_called_once ()
403+
404+ @responses .activate
405+ @override_options (CB_ENABLED )
406+ def test_500_response_does_not_record_error (self ) -> None :
389407 responses .add (
390408 responses .GET ,
391409 f"{ self .CELL .address } /server-error" ,
0 commit comments