From 53b25d61f7b47db309b2adbc0317e6ac7285a202 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Mon, 13 Feb 2023 12:06:29 +0100 Subject: [PATCH] events: use colon as separator for task name and task UID Signed-off-by: Jens Langhammer --- authentik/admin/signals.py | 2 +- authentik/events/monitored_tasks.py | 13 ++++--------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/authentik/admin/signals.py b/authentik/admin/signals.py index d6ca8fceb..f171fc74e 100644 --- a/authentik/admin/signals.py +++ b/authentik/admin/signals.py @@ -18,4 +18,4 @@ def monitoring_set_workers(sender, **kwargs): def monitoring_set_tasks(sender, **kwargs): """Set task gauges""" for task in TaskInfo.all().values(): - task.set_prom_metrics() + task.update_metrics() diff --git a/authentik/events/monitored_tasks.py b/authentik/events/monitored_tasks.py index 9d9c34560..3b7987e90 100644 --- a/authentik/events/monitored_tasks.py +++ b/authentik/events/monitored_tasks.py @@ -63,11 +63,6 @@ class TaskInfo: task_description: Optional[str] = field(default=None) - @property - def html_name(self) -> list[str]: - """Get task_name, but split on underscores, so we can join in the html template.""" - return self.task_name.split("_") - @staticmethod def all() -> dict[str, "TaskInfo"]: """Get all TaskInfo objects""" @@ -82,7 +77,7 @@ class TaskInfo: """Delete task info from cache""" return cache.delete(CACHE_KEY_PREFIX + self.task_name) - def set_prom_metrics(self): + def update_metrics(self): """Update prometheus metrics""" start = default_timer() if hasattr(self, "start_timestamp"): @@ -101,9 +96,9 @@ class TaskInfo: """Save task into cache""" key = CACHE_KEY_PREFIX + self.task_name if self.result.uid: - key += f"/{self.result.uid}" - self.task_name += f"/{self.result.uid}" - self.set_prom_metrics() + key += f":{self.result.uid}" + self.task_name += f":{self.result.uid}" + self.update_metrics() cache.set(key, self, timeout=timeout_hours * 60 * 60)