chore: OpenTelemetry 디버그 로그 추가
All checks were successful
Build And Test / build-and-push (push) Successful in 2m8s

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-25 12:56:53 +09:00
parent d87d70997b
commit bffd2c9c70

View File

@ -16,6 +16,7 @@ from django.conf import settings
from django.core.wsgi import get_wsgi_application
# DEBUG 모드 아닐 때만 OpenTelemetry 활성
print(f"[OTEL] DEBUG={settings.DEBUG}, TRACE_ENDPOINT={settings.TRACE_ENDPOINT}")
if not settings.DEBUG:
import grpc
from opentelemetry import trace
@ -41,13 +42,16 @@ if not settings.DEBUG:
# TRACE_CA_CERT 설정에 따른 gRPC credentials 구성
credentials = None
ca_cert_path = os.getenv('TRACE_CA_CERT', '').strip()
print(f"[OTEL] CA_CERT_PATH={ca_cert_path}, exists={os.path.exists(ca_cert_path) if ca_cert_path else False}")
if ca_cert_path and os.path.exists(ca_cert_path):
with open(ca_cert_path, 'rb') as f:
ca_cert = f.read()
credentials = grpc.ssl_channel_credentials(root_certificates=ca_cert)
insecure = False
print(f"[OTEL] Using TLS with CA cert")
else:
insecure = True
print(f"[OTEL] Using insecure mode")
otlp_exporter = OTLPSpanExporter(
endpoint=settings.TRACE_ENDPOINT,
@ -62,6 +66,7 @@ if not settings.DEBUG:
trace.get_tracer_provider().add_span_processor(
BatchSpanProcessor(otlp_exporter)
)
print(f"[OTEL] OpenTelemetry initialized: service={settings.TRACE_SERVICE_NAME}, endpoint={settings.TRACE_ENDPOINT}")
# Django 요청/응답 추적
DjangoInstrumentor().instrument()