Skip to content

Commit 39d35e1

Browse files
authored
refs(metric_alerts): Keep track of pending snapshot queue size (#21351)
We want to be able to track this so that we can alert if the queue grows too large.
1 parent a355bde commit 39d35e1

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/sentry/incidents/tasks.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,16 @@ def process_pending_incident_snapshots(next_id=None):
204204
"""
205205
from sentry.incidents.logic import create_incident_snapshot
206206

207+
if next_id is None:
208+
# When next_id is None we know we just started running the task. Take the count
209+
# of total pending snapshots so that we can alert if we notice the queue
210+
# constantly growing.
211+
metrics.incr(
212+
"incidents.pending_snapshots",
213+
amount=PendingIncidentSnapshot.objects.count(),
214+
sample_rate=1.0,
215+
)
216+
207217
now = timezone.now()
208218
pending_snapshots = PendingIncidentSnapshot.objects.filter(target_run_date__lte=now)
209219
if next_id is not None:

0 commit comments

Comments
 (0)