Skip to content

Queue Depth Utils #33

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

Merged
merged 21 commits into from
Dec 3, 2019
Merged

Queue Depth Utils #33

merged 21 commits into from
Dec 3, 2019

Conversation

jordaneb
Copy link
Member

@jordaneb jordaneb commented Nov 28, 2019

from django_dbq.models import Job


def test_task(job):
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this used?

Copy link
Member Author

Choose a reason for hiding this comment

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

that wasn't supposed to reach github :p

annotation_dicts = (
Job.objects.filter(state__in=(Job.STATES.READY, Job.STATES.NEW))
.values("queue_name")
.order_by()
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this line necessary? I don't think the order really matters here?

@RealOrangeOne
Copy link
Contributor

Is adding an implementation of #26 in scope for this PR?

@jordaneb
Copy link
Member Author

i don't see why not @RealOrangeOne -- that's where the idea came from in the first place :D

@@ -137,3 +137,17 @@ def run_creation_hook(self):
logger.info("Running creation hook %s for new job", creation_hook_name)
creation_hook_function = import_string(creation_hook_name)
creation_hook_function(self)

@staticmethod
def get_queue_depths_dict():
Copy link
Contributor

Choose a reason for hiding this comment

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

Thoughts on whether this needs the dict suffix? Putting the type in the method name feels weird

Suggested change
def get_queue_depths_dict():
def get_queue_depths():

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah that's a fair point! i'll update that


def handle(self, *args, **options):
queue_name = options["queue_name"]
queue_names = options["queue_name"]
Copy link
Member

Choose a reason for hiding this comment

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

Should we rename the argument to queue_names too for consistency?

Copy link
Member Author

Choose a reason for hiding this comment

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

so when i run manage.py queue_depth --help it outputs the following:

usage: manage.py queue_depth [-h] [--version] [-v {0,1,2,3}]
                             [--settings SETTINGS] [--pythonpath PYTHONPATH]
                             [--traceback] [--no-color]
                             [queue_name [queue_name ...]]

it would maybe look a little weird if that said queue_names instead?

Copy link
Member

Choose a reason for hiding this comment

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

Ah ok. Yes I do think it reads better like that, actually.

[
f"{queue_name}={queue_depths.get(queue_name, 0)}"
for queue_name in queue_names
]
Copy link
Member

Choose a reason for hiding this comment

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

I feel like if we're going to use this for cloudwatch metrics, we'll need a way to identify these log lines more unambiguously. Maybe write out something like "Queue depths: default=0" or event=queue_depths: default=0 or similar? (the latter would be better for us but maybe less "friendly"? Not sure..)

Copy link
Member Author

Choose a reason for hiding this comment

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

i think the latter is probably better for everyone, it's still human readable and more easily machine readable than the former

Copy link
Member

@j4mie j4mie left a comment

Choose a reason for hiding this comment

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

😎

@jordaneb jordaneb merged commit c2a126a into master Dec 3, 2019
@jordaneb jordaneb deleted the queue-depth-utils branch December 3, 2019 09:09
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