diff --git a/authentik/core/middleware.py b/authentik/core/middleware.py index 67ac896cb..5dadd1f27 100644 --- a/authentik/core/middleware.py +++ b/authentik/core/middleware.py @@ -65,4 +65,6 @@ def structlog_add_request_id(logger: Logger, method_name: str, event_dict: dict) """If threadlocal has authentik defined, add request_id to log""" if hasattr(LOCAL, "authentik"): event_dict.update(LOCAL.authentik) + if hasattr(LOCAL, "authentik_task"): + event_dict.update(LOCAL.authentik_task) return event_dict diff --git a/authentik/root/celery.py b/authentik/root/celery.py index 4698253b6..7267ae59a 100644 --- a/authentik/root/celery.py +++ b/authentik/root/celery.py @@ -43,9 +43,9 @@ def after_task_publish_hook(sender=None, headers=None, body=None, **kwargs): # pylint: disable=unused-argument @task_prerun.connect -def task_prerun_hook(task_id, task, *args, **kwargs): +def task_prerun_hook(task_id: str, task, *args, **kwargs): """Log task_id on worker""" - request_id = "task-" + uuid4().hex[5:] + request_id = "task-" + task_id.replace("-", "") LOCAL.authentik_task = { "request_id": request_id, }