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
1 changed files with 7 additions and 1 deletions

View File

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