Skip to content

Commit 8b2dac3

Browse files
authored
[Monitoring] Adding a counter metric for rate limit events (#4394)
### Motivation Adding a metric to keep track of rate limits Part of #4271
1 parent ce75106 commit 8b2dac3

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/clusterfuzz/_internal/bot/tasks/commands.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
from clusterfuzz._internal.datastore import data_handler
4040
from clusterfuzz._internal.datastore import data_types
4141
from clusterfuzz._internal.metrics import logs
42+
from clusterfuzz._internal.metrics import monitoring_metrics
4243
from clusterfuzz._internal.system import environment
4344
from clusterfuzz._internal.system import process_handler
4445
from clusterfuzz._internal.system import shell
@@ -211,6 +212,11 @@ def run_command(task_name, task_argument, job_name, uworker_env):
211212
rate_limiter = task_rate_limiting.TaskRateLimiter(task_name, task_argument,
212213
job_name)
213214
if rate_limiter.is_rate_limited():
215+
monitoring_metrics.TASK_RATE_LIMIT_COUNT.increment(labels={
216+
'job': job_name,
217+
'task': task_name,
218+
'argument': task_argument,
219+
})
214220
logs.error(f'Rate limited task: {task_name} {task_argument} {job_name}')
215221
if task_name == 'fuzz':
216222
# Wait 10 seconds. We don't want to try again immediately because if we

src/clusterfuzz/_internal/metrics/monitoring_metrics.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,15 @@
195195
],
196196
)
197197

198+
TASK_RATE_LIMIT_COUNT = monitor.CounterMetric(
199+
'task/rate_limit',
200+
description=('Counter for rate limit events.'),
201+
field_spec=[
202+
monitor.StringField('task'),
203+
monitor.StringField('job'),
204+
monitor.StringField('argument'),
205+
])
206+
198207
UTASK_SUBTASK_E2E_DURATION_SECS = monitor.CumulativeDistributionMetric(
199208
'utask/subtask_e2e_duration_secs',
200209
description=(

0 commit comments

Comments
 (0)