Skip to content

Commit

Permalink
Debug log for scheduler commit duration (ansible#14035)
Browse files Browse the repository at this point in the history
Co-authored-by: Alan Rominger <[email protected]>
  • Loading branch information
TheRealHaoLiu and AlanCoding authored Sep 27, 2023
1 parent a88e479 commit bb3acbb
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion awx/main/scheduler/task_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ def record_aggregate_metrics_and_exit(self, *args):
self.record_aggregate_metrics()
sys.exit(1)

def get_local_metrics(self):
data = {}
for k, metric in self.subsystem_metrics.METRICS.items():
if k.startswith(self.prefix) and metric.metric_has_changed:
data[k[len(self.prefix) + 1 :]] = metric.current_value
return data

def schedule(self):
# Always be able to restore the original signal handler if we finish
original_sigusr1 = signal.getsignal(signal.SIGUSR1)
Expand All @@ -146,10 +153,14 @@ def schedule(self):
signal.signal(signal.SIGUSR1, original_sigusr1)
commit_start = time.time()

logger.debug(f"Commiting {self.prefix} Scheduler changes")

if self.prefix == "task_manager":
self.subsystem_metrics.set(f"{self.prefix}_commit_seconds", time.time() - commit_start)
local_metrics = self.get_local_metrics()
self.record_aggregate_metrics()
logger.debug(f"Finishing {self.prefix} Scheduler")

logger.debug(f"Finished {self.prefix} Scheduler, timing data:\n{local_metrics}")


class WorkflowManager(TaskBase):
Expand Down

0 comments on commit bb3acbb

Please sign in to comment.