Skip to content

fix(taskworker) Add metric to see how long we wait #94864

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 2 commits into from
Jul 4, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/sentry/taskworker/workerchild.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ def handle_alarm(signum: int, frame: FrameType | None) -> None:

while True:
if max_task_count and processed_task_count >= max_task_count:

metrics.incr(
"taskworker.worker.max_task_count_reached",
tags={"count": processed_task_count, "processing_pool": processing_pool_name},
Expand All @@ -176,9 +175,16 @@ def handle_alarm(signum: int, frame: FrameType | None) -> None:
logger.info("taskworker.worker.shutdown_event")
break

child_tasks_get_start = time.monotonic()
try:
# If the queue is empty, this could block for a second.
inflight = child_tasks.get(timeout=1.0)
except queue.Empty:
metrics.distribution(
"taskworker.worker.child_task_queue_empty.wait_duration",
time.monotonic() - child_tasks_get_start,
tags={"processing_pool": processing_pool_name},
)
metrics.incr(
"taskworker.worker.child_task_queue_empty",
tags={"processing_pool": processing_pool_name},
Expand Down
Loading