|
27 | 27 | from snuba_sdk.legacy import json_to_snql
|
28 | 28 | from snuba_sdk.query import SelectableExpression
|
29 | 29 |
|
30 |
| -from sentry import options |
31 | 30 | from sentry.api.helpers.error_upsampling import (
|
32 | 31 | UPSAMPLED_ERROR_AGGREGATION,
|
33 | 32 | are_any_projects_error_upsampled,
|
@@ -1256,34 +1255,33 @@ def _bulk_snuba_query(snuba_requests: Sequence[SnubaRequest]) -> ResultSet:
|
1256 | 1255 | if body.get("error"):
|
1257 | 1256 | error = body["error"]
|
1258 | 1257 | if response.status == 429:
|
1259 |
| - if options.get("issues.use-snuba-error-data"): |
1260 |
| - try: |
1261 |
| - if ( |
1262 |
| - "quota_allowance" not in body |
1263 |
| - or "summary" not in body["quota_allowance"] |
1264 |
| - ): |
1265 |
| - # Should not hit this - snuba gives us quota_allowance with a 429 |
1266 |
| - raise RateLimitExceeded(error["message"]) |
1267 |
| - quota_allowance_summary = body["quota_allowance"]["summary"] |
1268 |
| - rejected_by = quota_allowance_summary["rejected_by"] |
1269 |
| - throttled_by = quota_allowance_summary["throttled_by"] |
1270 |
| - |
1271 |
| - policy_info = rejected_by or throttled_by |
1272 |
| - |
1273 |
| - if policy_info: |
1274 |
| - raise RateLimitExceeded( |
1275 |
| - error["message"], |
1276 |
| - policy=policy_info["policy"], |
1277 |
| - quota_unit=policy_info["quota_unit"], |
1278 |
| - storage_key=policy_info["storage_key"], |
1279 |
| - quota_used=policy_info["quota_used"], |
1280 |
| - rejection_threshold=policy_info["rejection_threshold"], |
1281 |
| - ) |
1282 |
| - except KeyError: |
1283 |
| - logger.warning( |
1284 |
| - "Failed to parse rate limit error details from Snuba response", |
1285 |
| - extra={"error": error["message"]}, |
| 1258 | + try: |
| 1259 | + if ( |
| 1260 | + "quota_allowance" not in body |
| 1261 | + or "summary" not in body["quota_allowance"] |
| 1262 | + ): |
| 1263 | + # Should not hit this - snuba gives us quota_allowance with a 429 |
| 1264 | + raise RateLimitExceeded(error["message"]) |
| 1265 | + quota_allowance_summary = body["quota_allowance"]["summary"] |
| 1266 | + rejected_by = quota_allowance_summary["rejected_by"] |
| 1267 | + throttled_by = quota_allowance_summary["throttled_by"] |
| 1268 | + |
| 1269 | + policy_info = rejected_by or throttled_by |
| 1270 | + |
| 1271 | + if policy_info: |
| 1272 | + raise RateLimitExceeded( |
| 1273 | + error["message"], |
| 1274 | + policy=policy_info["policy"], |
| 1275 | + quota_unit=policy_info["quota_unit"], |
| 1276 | + storage_key=policy_info["storage_key"], |
| 1277 | + quota_used=policy_info["quota_used"], |
| 1278 | + rejection_threshold=policy_info["rejection_threshold"], |
1286 | 1279 | )
|
| 1280 | + except KeyError: |
| 1281 | + logger.warning( |
| 1282 | + "Failed to parse rate limit error details from Snuba response", |
| 1283 | + extra={"error": error["message"]}, |
| 1284 | + ) |
1287 | 1285 |
|
1288 | 1286 | raise RateLimitExceeded(error["message"])
|
1289 | 1287 |
|
|
0 commit comments