Skip to content

Commit

Permalink
code
Browse files Browse the repository at this point in the history
  • Loading branch information
Rachel Chen authored and Rachel Chen committed Jul 2, 2024
1 parent f8e1456 commit 7585288
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 4 additions & 0 deletions snuba/web/db_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,7 @@ def _apply_allocation_policies_quota(
Sets the resource quota in the query_settings object to the minimum of all available
quota allowances from the given allocation policies.
"""
metrics.increment("db_query_single_query")
quota_allowances: dict[str, Any] = {}
can_run = True
rejection_quota_and_policy = None
Expand Down Expand Up @@ -901,6 +902,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
Expand Down

0 comments on commit 7585288

Please sign in to comment.