fix startup

Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space>
This commit is contained in:
Marc 'risson' Schmitt 2023-12-28 12:41:51 +01:00
parent e8747a5a30
commit a6a1c96d44
No known key found for this signature in database
GPG key ID: 9C3FA22FABF1AA8D

View file

@ -6,6 +6,7 @@ from timeit import default_timer
from typing import Any, Optional
from django.core.cache import cache
from django.db.utils import ProgrammingError
from django.utils.translation import gettext_lazy as _
from structlog.stdlib import get_logger
from tenant_schemas_celery.task import TenantTask
@ -101,8 +102,13 @@ class TaskInfo:
duration = max(self.finish_timestamp - start, 0)
except TypeError:
duration = 0
try:
tenant = get_current_tenant().tenant_uuid
# DB not yet initialized, let's not fail
except ProgrammingError:
tenant = ""
GAUGE_TASKS.labels(
tenant=get_current_tenant().tenant_uuid,
tenant=tenant,
task_name=self.task_name.split(":")[0],
task_uid=self.result.uid or "",
status=self.result.status.name.lower(),