Skip to content

Emit celery.failed_task=0 on success so the failure metric stays dense#339

Merged
maperu merged 2 commits into
masterfrom
maperu/celeryFailedZero
Jul 21, 2026
Merged

Emit celery.failed_task=0 on success so the failure metric stays dense#339
maperu merged 2 commits into
masterfrom
maperu/celeryFailedZero

Conversation

@maperu

@maperu maperu commented Jul 17, 2026

Copy link
Copy Markdown

celery.failed_task was emitted only on task failure as a TIMER, so lemur.celery.failed_task.count was sparse (no data when nothing fails) and the persistent-failures monitor (299971237) had to wrap it in default_zero to read 0 when healthy.

This makes failed_task a counter and emits 0 on every task success, with a low-cardinality task_name tag only, not the full request tags that carry task_id. So the metric is continuously present, 0 when healthy and greater than 0 on failures, and the monitor can drop default_zero.

Heads up: this renames the Datadog metric from lemur.celery.failed_task.count to lemur.celery.failed_task (counters have no .count suffix). The monitor query changes in a companion terraform-config PR, and this one should deploy first so the new counter is flowing before that monitor switches, otherwise it briefly queries a metric with no data. Anything else reading failed_task.count (e.g. the Celery Task Health group on the nqu-dbc-mtt dashboard) needs the same rename. This diverges from upstream, which emits failed_task as a TIMER.

failed_task was a TIMER emitted only on failure, so lemur.celery.failed_task.count was sparse and the persistent-failures monitor had to default_zero it. Make failed_task a counter and emit 0 on every task success (low-cardinality task_name tag only), so it reads 0 when healthy and >0 on failures without query-side gap-filling. This renames the DD metric to lemur.celery.failed_task (counters have no .count suffix); the monitor query changes in a companion terraform-config PR. Deploy this first so the counter is flowing before that switch.
@maperu
maperu marked this pull request as ready for review July 20, 2026 20:57
@maperu
maperu requested a review from a team as a code owner July 20, 2026 20:58
Comment thread lemur/common/celery.py
@maperu
maperu enabled auto-merge (squash) July 20, 2026 21:00
@maperu
maperu requested a review from evan-datadog July 20, 2026 21:02
@maperu
maperu requested a review from a team as a code owner July 21, 2026 20:55
@maperu
maperu merged commit bc51590 into master Jul 21, 2026
10 of 11 checks passed
@maperu
maperu deleted the maperu/celeryFailedZero branch July 21, 2026 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants