Skip to content

feat(TaskProducer): add metrics on queue size#681

Merged
bmckerry merged 3 commits into
mainfrom
ben/taskproducer-report-pending-futures
Jun 5, 2026
Merged

feat(TaskProducer): add metrics on queue size#681
bmckerry merged 3 commits into
mainfrom
ben/taskproducer-report-pending-futures

Conversation

@bmckerry
Copy link
Copy Markdown
Member

@bmckerry bmckerry commented Jun 5, 2026

This updates TaskProducer to take a metrics backend, and reports a gauge metric based on its pending_futures queue size.
We can use this to alert if a TaskProducer instance is going to reach its future queue max size, leading to dropped futures.

@bmckerry bmckerry requested a review from a team as a code owner June 5, 2026 17:53
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 383993e. Configure here.

"task.producer.pending.futures",
len(_pending_futures),
tags={"producer_name": self.name},
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gauge stale after queue cleared

Medium Severity

task.producer.pending.futures is updated only in track_future when a future is appended, but collect_futures clears _pending_futures without recording a gauge. After each activation (including when the queue is empty), dashboards can still show the last non-zero size and trigger false queue-pressure alerts.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 383993e. Configure here.

"task.producer.pending.futures",
len(_pending_futures),
tags={"producer_name": self.name},
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Producer tag omits other producers

Medium Severity

The gauge uses producer_name but reports len(_pending_futures), a global deque shared by every TaskProducer. Only the instance that called track_future updates its tag, so another producer’s futures can leave that series stale and under-report true queue pressure for that name.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 383993e. Configure here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_pending_futures is global out of necessity, but there should generally only be 1 TaskProducer instance per worker replica.

Base automatically changed from ben/taskproducer-bounded-queue to main June 5, 2026 18:01
@bmckerry bmckerry merged commit 07daf36 into main Jun 5, 2026
27 checks passed
@bmckerry bmckerry deleted the ben/taskproducer-report-pending-futures branch June 5, 2026 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants