events: improve logging for task exceptions

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-08-30 14:43:44 +02:00
parent a016f99450
commit 63f57b6a77
1 changed files with 2 additions and 3 deletions

View File

@ -11,6 +11,7 @@ from django.core.cache import cache
from prometheus_client import Gauge
from authentik.events.models import Event, EventAction
from authentik.lib.utils.errors import exception_to_string
GAUGE_TASKS = Gauge(
"authentik_system_tasks",
@ -174,9 +175,7 @@ class MonitoredTask(Task):
).save(self.result_timeout_hours)
Event.new(
EventAction.SYSTEM_TASK_EXCEPTION,
message=(
f"Task {self.__name__} encountered an error: " "\n".join(self._result.messages)
),
message=(f"Task {self.__name__} encountered an error: {exception_to_string(exc)}"),
).save()
return super().on_failure(exc, task_id, args, kwargs, einfo=einfo)