-
Notifications
You must be signed in to change notification settings - Fork 50
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
Metrics for stuck async requests #471
Conversation
@@ -112,13 +118,17 @@ def after_return( | |||
# See documentation for options: | |||
# https://docs.celeryproject.org/en/stable/userguide/tasks.html#list-of-options | |||
@app.task(base=ErrorHandlingTask, name=LIRA_CELERY_TASK_NAME, track_started=True) | |||
def exec_func(payload, *ignored_args, **ignored_kwargs): | |||
def exec_func(payload, arrival_timestamp, *ignored_args, **ignored_kwargs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update L#144 too?
return forwarder(payload) | ||
result = forwarder(payload) | ||
request_duration = datetime.now() - arrival_timestamp | ||
if request_duration > timedelta(hours=12): # longer than default visibility timeout |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can u set as global constant near the task visibility enum?
result = forwarder(payload) | ||
request_duration = datetime.now() - arrival_timestamp | ||
if request_duration > timedelta(hours=12): # longer than default visibility timeout | ||
monitoring_metrics_gateway.emit_async_task_stuck_metric(queue_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh wait would we also want to emit "tasks not stuck" metrics? so we have some ratio
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm ok, will just add an "else" block for another metric... is it ok if that doesn't cover tasks that fail or tasks that get stuck but have visibility timeout < 12 hours? 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or actually, I can emit an "we got an async task" metric right when the forwarder receives requests, which will also track the ratio? 😮
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's probably fine, yeah
I feel like we should be emitting some metric for the gateway creating an async task already, although it's gonna be harder to correlate because of time
Pull Request Summary
Add custom metric
Test Plan and Usage Guide
How did you validate that your PR works correctly? How do you run or demo the code? Provide enough detail so a reviewer can reasonably reproduce the testing procedure. Paste example command line invocations if applicable.