Add OpenTelemetry integration

This commit is contained in:
Oliver Falk
2025-10-16 15:22:54 +02:00
parent 2c5e7ab90f
commit a9021fc0f7
17 changed files with 2269 additions and 62 deletions

View File

@@ -34,6 +34,9 @@ MIDDLEWARE.extend(
"ivatar.middleware.CustomLocaleMiddleware",
]
)
# Add OpenTelemetry middleware only if feature flag is enabled
# Note: This will be checked at runtime, not at import time
MIDDLEWARE.insert(
0,
"ivatar.middleware.MultipleProxyMiddleware",
@@ -309,6 +312,13 @@ ENABLE_MALICIOUS_CONTENT_SCAN = True
# Logging configuration - can be overridden in local config
# Example: LOGS_DIR = "/var/log/ivatar" # For production deployments
# OpenTelemetry feature flag - can be disabled for F/LOSS deployments
ENABLE_OPENTELEMETRY = os.environ.get("ENABLE_OPENTELEMETRY", "false").lower() in (
"true",
"1",
"yes",
)
# This MUST BE THE LAST!
if os.path.isfile(os.path.join(BASE_DIR, "config_local.py")):
from config_local import * # noqa # flake8: noqa # NOQA # pragma: no cover