feat(api/observability): bootstrap OpenTelemetry in wsgi/asgi/manage entry points

This commit is contained in:
sriram veeraghanta
2026-07-14 01:10:26 +05:30
parent 810b8c89e8
commit cd3f0042fb
3 changed files with 25 additions and 10 deletions

View File

@@ -8,6 +8,13 @@ import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "plane.settings.production")
# Bootstrap OpenTelemetry before Django imports so runserver and
# management commands are instrumented too. No-op unless OTEL_ENABLED=1.
from plane.observability.setup import configure_otel
configure_otel()
try:
from django.core.management import execute_from_command_line
except ImportError as exc:

View File

@@ -4,15 +4,17 @@
import os
from channels.routing import ProtocolTypeRouter
from django.core.asgi import get_asgi_application
django_asgi_app = get_asgi_application()
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "plane.settings.production")
# Bootstrap OpenTelemetry before Django wires up so DjangoInstrumentor can
# patch the ASGI handler. No-op unless OTEL_ENABLED=1.
from plane.observability.setup import configure_otel # noqa: E402
configure_otel()
from channels.routing import ProtocolTypeRouter # noqa: E402
from django.core.asgi import get_asgi_application # noqa: E402
# Initialize Django ASGI application early to ensure the AppRegistry
# is populated before importing code that may import ORM models.
application = ProtocolTypeRouter({"http": get_asgi_application()})

View File

@@ -11,8 +11,14 @@ It exposes the WSGI callable as a module-level variable named ``application``.
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "plane.settings.production")
# Bootstrap OpenTelemetry before Django wires up so DjangoInstrumentor can
# patch the WSGI handler. No-op unless OTEL_ENABLED=1.
from plane.observability.setup import configure_otel # noqa: E402
configure_otel()
from django.core.wsgi import get_wsgi_application # noqa: E402
application = get_wsgi_application()