schon/schon/settings/caches.py
Egor fureunoir Gorbunov 069d416585 refactor(monitoring): remove django-prometheus integration
Replaced `django-prometheus` with the default Django components, including model mixins, database backends, and cache configuration. This change simplifies monitoring setup by removing unnecessary dependencies, reducing overhead, and improving compatibility.

**Details:**
- Removed Prometheus metrics endpoints and middleware.
- Updated database, cache, and model configurations to remove `django-prometheus`.
- Adjusted WSGI settings to integrate OpenTelemetry instrumentation instead of Prometheus.
- Updated dependency files and migration schemas accordingly.
2026-02-21 23:44:15 +03:00

38 lines
1.1 KiB
Python

import sys
from os import getenv
from schon.settings.base import REDIS_PASSWORD
CACHES = {
"default": {
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": getenv(
"CELERY_BROKER_URL", f"redis://:{REDIS_PASSWORD}@redis:6379/0"
),
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient",
"SOCKET_CONNECT_TIMEOUT": 5,
"SOCKET_TIMEOUT": 5,
"RETRY_ON_TIMEOUT": True,
"CONNECTION_POOL_KWARGS": {
"retry_on_timeout": True,
"socket_keepalive": True,
},
"IGNORE_EXCEPTIONS": True,
},
}
}
if any(arg == "celery" for arg in sys.argv):
CACHEOPS_ENABLED = False
else:
CACHEOPS_ENABLED = True
CACHEOPS_REDIS = f"redis://:{REDIS_PASSWORD}@redis:6379/0"
CACHEOPS = {
"vibes_auth.user": {"ops": "get", "timeout": 60 * 15},
"vibes_auth.*": {"ops": {"fetch", "get"}, "timeout": 60 * 60},
"vibes_auth.permission": {"ops": "all", "timeout": 60 * 60},
"core.*": {"ops": "all", "timeout": 60 * 60},
}