Skip to content

Commit

Permalink
Change some variable names.
Browse files Browse the repository at this point in the history
Close #3821
  • Loading branch information
decko committed Apr 29, 2024
1 parent 3447aa2 commit 35caff4
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions pulpcore/tasking/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,14 +407,14 @@ def record_unblocked_waiting_tasks_metric(self):
TASK_METRICS_HEARTBEAT_LOCK
):
meter = get_meter(__name__)
unblocked_waiting_tasks_meter = meter.create_gauge(
tasks_unblocked_waiting_tasks_queue_meter = meter.create_gauge(
name="tasks_unblocked_waiting_queue",
description="Number of unblocked tasks waiting in the queue.",
unit="tasks",
)

longest_waiting_tasks_meter = meter.create_gauge(
name="tasks_longest_waiting_task",
tasks_longest_unblocked_waiting_time_meter = meter.create_gauge(
name="tasks_longest_unblocked_waiting_time",
description="The age of the longest waiting task.",
unit="seconds",
)
Expand All @@ -426,8 +426,10 @@ def record_unblocked_waiting_tasks_metric(self):
unblocked_for=Value(timezone.now()) - F("unblocked_at")
)
unblocked_waiting_tasks_aggregated = unblocked_waiting_tasks_annotated.aggregate(
longest_age=Max("unblocked_for", default=timezone.timedelta(0)),
unblocked_count_gte_threshold=Count(
longest_unblocked_waiting_time=Max(
"unblocked_for", default=timezone.timedelta(0)
),
unblocked_tasks_count_gte_threshold=Count(
Case(
When(
unblocked_for__gte=Value(
Expand All @@ -439,11 +441,11 @@ def record_unblocked_waiting_tasks_metric(self):
),
)

unblocked_waiting_tasks_meter.set(
unblocked_waiting_tasks_aggregated["unblocked_count_gte_threshold"]
tasks_unblocked_waiting_tasks_queue_meter.set(
unblocked_waiting_tasks_aggregated["unblocked_tasks_count_gte_threshold"]
)
longest_waiting_tasks_meter.set(
unblocked_waiting_tasks_aggregated["longest_age"].seconds
tasks_longest_unblocked_waiting_time_meter.set(
unblocked_waiting_tasks_aggregated["longest_unblocked_waiting_time"].seconds
)

self.cursor.execute(f"NOTIFY pulp_worker_metrics_heartbeat, '{str(now)}'")
Expand Down

0 comments on commit 35caff4

Please sign in to comment.