tracing add
All checks were successful
Build And Test / build-and-push (push) Successful in 4m19s

This commit is contained in:
2025-04-14 15:28:57 +09:00
parent 2796994608
commit f860373c70
4 changed files with 67 additions and 12 deletions

View File

@ -1,16 +1,38 @@
"""
WSGI config for butler_ddochi 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', 'butler_ddochi.settings')
from django.conf import settings # <<<< 이거 추가
# ✅ 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.name": "butler_ddochi",
})
)
)
otlp_exporter = OTLPSpanExporter(
endpoint="http://jaeger-collector:4317",
insecure=True,
)
trace.get_tracer_provider().add_span_processor(
BatchSpanProcessor(otlp_exporter)
)
DjangoInstrumentor().instrument()
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'butler_ddochi.settings')
application = get_wsgi_application()

View File

@ -0,0 +1,16 @@
"""
WSGI config for butler_ddochi 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
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'butler_ddochi.settings')
application = get_wsgi_application()