Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include zeros for missing queue states in Oban polling metrics #245

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

martinsvalin-kivra
Copy link

Change description

This changes Oban polling metrics to include zeros for all missing queue + state combinations in the Oban jobs table. Queues are taken from the Oban config, and Oban exposes all possible states in Oban.Job.states/0.

What problem does this solve?

The polling query will only count jobs that exist in the table, so naturally no zeros will be returned. When counts for a particular queue state combination is present and then disappears from one poll to the next, some tools will show the stale last-seen count, when the true count is zero. A spike in available or executing jobs that is quickly processed can lead to a misleading count hanging around.

My team at work had this issue, and we're running a copy of the Oban plugin for now, with these changes.

A possible downside of this change is a larger metrics payload, in cases with a lot of mostly-empty queues. We only have 5 fairly busy queues.

Issue number: #202

Checklist

  • I have added unit tests to cover my changes.
  • I have added documentation to cover my changes.
  • My changes have passed unit tests and have been tested E2E in an example project.

Sorry about the absence of tests. It looked like adding tests for this would be fairly invasive in the current test suite.

DB query will only count jobs that exist. When counts for a particular queue state combination disappears from one poll to the next, some tools will show the stale last-seen count, when the true count is zero.

This change will include zeros for all missing queue + state combinations. Queues are taken from the Oban config, and Oban exposes all possible states in `Oban.Job.states/0`.

This addresses issue akoutmos#202
@benonymus
Copy link
Contributor

This is a real issue we are running into as well. Dashboards get stuck on high counts and trigger alerts because they are unable to go to 0.

@benonymus
Copy link
Contributor

benonymus commented Oct 11, 2024

This fix only works in the classic oban setup. If you use https://hexdocs.pm/oban/2.11.0/dynamic_queues.html
the list of queues is not in under Oban.config().queues.
It is inside the plugins: https://hexdocs.pm/oban/2.11.0/dynamic_queues.html#using-and-configuring

Something like this should handle both cases:
benonymus@d5a56d0

EDIT:
I validated in our application that the dynamic queues case is handled with my small change to this pr.

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.

3 participants