|
14 | 14 | from django.http.response import HttpResponseBase |
15 | 15 | from requests import Response as ExternalResponse |
16 | 16 | from requests import request as external_request |
17 | | -from requests.exceptions import Timeout |
| 17 | +from requests.exceptions import ConnectionError, Timeout |
18 | 18 |
|
19 | 19 | from sentry import options |
20 | 20 | from sentry.api.exceptions import RequestTimeout |
@@ -193,18 +193,22 @@ def proxy_cell_request(request: HttpRequest, cell: Cell, url_name: str) -> HttpR |
193 | 193 | ) |
194 | 194 | except Timeout: |
195 | 195 | metrics.incr("apigateway.proxy.request_timeout", tags=metric_tags) |
196 | | - try: |
197 | | - if circuit_breaker is not None: |
198 | | - circuit_breaker.record_error() |
199 | | - except Exception: |
200 | | - logger.exception("Failed to record circuitbreaker failure") |
| 196 | + if circuit_breaker is not None: |
| 197 | + circuit_breaker.record_error() |
201 | 198 |
|
202 | 199 | # remote silo timeout. Use DRF timeout instead |
203 | 200 | raise RequestTimeout() |
| 201 | + except ConnectionError: |
| 202 | + metrics.incr("apigateway.proxy.connection_error", tags=metric_tags) |
| 203 | + if circuit_breaker is not None: |
| 204 | + circuit_breaker.record_error() |
| 205 | + |
| 206 | + raise |
204 | 207 |
|
205 | | - if resp.status_code >= 500 and circuit_breaker is not None: |
| 208 | + if resp.status_code >= 502: |
206 | 209 | metrics.incr("apigateway.proxy.request_failed", tags=metric_tags) |
207 | | - circuit_breaker.record_error() |
| 210 | + if circuit_breaker is not None: |
| 211 | + circuit_breaker.record_error() |
208 | 212 |
|
209 | 213 | new_headers = clean_outbound_headers(resp.headers) |
210 | 214 | resp.headers.clear() |
|
0 commit comments