From 8a00dca98f9064af1f6cbd73ab8dac236323133f Mon Sep 17 00:00:00 2001 From: xurui-c <159840875+xurui-c@users.noreply.github.com> Date: Tue, 2 Jul 2024 13:02:59 -0700 Subject: [PATCH] code (#6081) Co-authored-by: Rachel Chen --- .../query/allocation_policies/bytes_scanned_window_policy.py | 4 ++++ snuba/web/db_query.py | 3 +++ 2 files changed, 7 insertions(+) diff --git a/snuba/query/allocation_policies/bytes_scanned_window_policy.py b/snuba/query/allocation_policies/bytes_scanned_window_policy.py index fda7e295bd..2663e5e755 100644 --- a/snuba/query/allocation_policies/bytes_scanned_window_policy.py +++ b/snuba/query/allocation_policies/bytes_scanned_window_policy.py @@ -216,6 +216,10 @@ def _get_quota_allowance( granted_quota = granted_quotas[0] is_throttled = False if granted_quota.granted <= 0: + self.metrics.increment( + "bytes_scanned_window_policy_throttle", + tags={"referrer": str(referrer)}, + ) is_throttled = True explanation[ "reason" diff --git a/snuba/web/db_query.py b/snuba/web/db_query.py index f2f362830c..7bdfe76c5f 100644 --- a/snuba/web/db_query.py +++ b/snuba/web/db_query.py @@ -901,6 +901,9 @@ def _apply_allocation_policies_quota( _add_quota_info(summary, _THROTTLED_BY, throttle_quota_and_policy) stats["quota_allowance"]["summary"] = summary + if throttle_quota_and_policy is not None: + metrics.increment("db_query_throttled_query") + if not can_run: raise AllocationPolicyViolations.from_args(stats["quota_allowance"]) # Before allocation policies were a thing, the query pipeline would apply