Skip to content

feat: Celery metrics#32

Merged
adinhodovic merged 10 commits intomainfrom
celery-metrics
Feb 27, 2026
Merged

feat: Celery metrics#32
adinhodovic merged 10 commits intomainfrom
celery-metrics

Conversation

@adinhodovic
Copy link
Copy Markdown
Owner

No description provided.

@github-actions github-actions Bot added the feat label Feb 27, 2026
@adinhodovic adinhodovic force-pushed the celery-metrics branch 2 times, most recently from 4e146ba to db0e1e4 Compare February 27, 2026 16:26
Tests that call setup functions directly now use make_config() from
conftest.py so direct key access in library code never raises KeyError
when a key is absent from a hand-rolled dict.
…ric init

When PROMETHEUS_MULTIPROC_DIR is set in the environment (e.g. via Docker
Compose), prometheus_client switches to multiprocess mode at import time.
If the directory doesn't exist yet, the first metric object creation —
which happens during model import inside AppConfig.ready() — raises
FileNotFoundError.

_ensure_existing_multiproc_dir() now runs early in setup_metrics_for_django,
before the URL resolver check, so the dir is guaranteed to exist before any
downstream model import can trigger a .db file write.

Also removes the stale PROFILING.TAGS key from dev.py (removed in the
config cleanup that introduced RESOURCE_ATTRIBUTES).
@adinhodovic adinhodovic force-pushed the celery-metrics branch 2 times, most recently from 0a8d311 to d517373 Compare February 27, 2026 16:28
The previous attempt to create the dir in setup_metrics_for_django()
was still too late: prometheus_client tries to write .db files during
model import (Django Phase 2), but AppConfig.ready() only runs in
Phase 3.

django_o11y/__init__.py is imported in Phase 1 (app module discovery),
before any model is imported, so creating the directory there is the
earliest safe point. The stale _ensure_existing_multiproc_dir() helper
in metrics/setup.py is removed since it was redundant.
@adinhodovic adinhodovic merged commit b426d55 into main Feb 27, 2026
10 checks passed
@adinhodovic adinhodovic deleted the celery-metrics branch February 27, 2026 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant