Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
Jens Langhammer 2024-01-13 23:07:40 +01:00
parent 82e27a7458
commit 4a6f956c28
No known key found for this signature in database
3 changed files with 6 additions and 2 deletions

View File

@ -41,9 +41,11 @@ class SystemTaskSerializer(ModelSerializer):
return instance.name return instance.name
def get_start_timestamp(self, instance: SystemTask) -> datetime: def get_start_timestamp(self, instance: SystemTask) -> datetime:
"""Timestamp when the task started"""
return datetime.fromtimestamp(instance.start_timestamp, tz=timezone.utc) return datetime.fromtimestamp(instance.start_timestamp, tz=timezone.utc)
def get_finish_timestamp(self, instance: SystemTask) -> datetime: def get_finish_timestamp(self, instance: SystemTask) -> datetime:
"""Timestamp when the task finished"""
return datetime.fromtimestamp(instance.finish_timestamp, tz=timezone.utc) return datetime.fromtimestamp(instance.finish_timestamp, tz=timezone.utc)
def get_duration(self, instance: SystemTask) -> float: def get_duration(self, instance: SystemTask) -> float:

View File

@ -625,13 +625,13 @@ class SystemTask(SerializerModel, ExpiringModel):
duration = max(self.finish_timestamp - self.start_timestamp, 0) duration = max(self.finish_timestamp - self.start_timestamp, 0)
# TODO: Deprecated metric - remove in 2024.2 or later # TODO: Deprecated metric - remove in 2024.2 or later
GAUGE_TASKS.labels( GAUGE_TASKS.labels(
task_name=self.name.split(":")[0], task_name=self.name,
task_uid=self.uid or "", task_uid=self.uid or "",
status=self.status.lower(), status=self.status.lower(),
).set(duration) ).set(duration)
SYSTEM_TASK_TIME.observe(duration) SYSTEM_TASK_TIME.observe(duration)
SYSTEM_TASK_STATUS.labels( SYSTEM_TASK_STATUS.labels(
task_name=self.name.split(":")[0], task_name=self.name,
task_uid=self.uid or "", task_uid=self.uid or "",
status=self.status.lower(), status=self.status.lower(),
).inc() ).inc()

View File

@ -42719,10 +42719,12 @@ components:
start_timestamp: start_timestamp:
type: string type: string
format: date-time format: date-time
description: Timestamp when the task started
readOnly: true readOnly: true
finish_timestamp: finish_timestamp:
type: string type: string
format: date-time format: date-time
description: Timestamp when the task finished
readOnly: true readOnly: true
duration: duration:
type: number type: number