Files
msa-django-auth/auth_prj/wsgi.py
icurfer 64032861e0
All checks were successful
Build And Test / build-and-push (push) Successful in 2m29s
[update] header test
2025-12-08 13:52:54 +09:00

58 lines
1.8 KiB
Python

"""
WSGI config for auth_prj project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/4.2/howto/deployment/wsgi/
"""
import os
# ✅ Django 설정을 미리 불러온다 // 모듈 이름 주의
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'auth_prj.settings')
from django.conf import settings
from django.core.wsgi import get_wsgi_application
# ✅ DEBUG 모드 아닐 때만 OpenTelemetry 활성
if not settings.DEBUG:
from opentelemetry import trace
from opentelemetry.sdk.resources import Resource
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter
from opentelemetry.instrumentation.django import DjangoInstrumentor
trace.set_tracer_provider(
TracerProvider(
resource=Resource.create({
"service.platform": settings.SERVICE_PLATFORM,
# "service.name": "msa-django-auth",
"service.name": settings.TRACE_SERVICE_NAME,
})
)
)
otlp_exporter = OTLPSpanExporter(
# endpoint="http://jaeger-collector.istio-system:4317",
# endpoint="jaeger-collector.observability.svc.cluster.local:4317",
endpoint=settings.TRACE_ENDPOINT,
insecure=True,
headers={
"X-Scope-OrgID": settings.SERVICE_PLATFORM,
"X-Service": settings.TRACE_SERVICE_NAME
}
)
trace.get_tracer_provider().add_span_processor(
BatchSpanProcessor(otlp_exporter)
)
DjangoInstrumentor().instrument()
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()