chore: OpenTelemetry 디버그 로그 추가
All checks were successful
Build And Test / build-and-push (push) Successful in 2m8s
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:
@ -16,6 +16,7 @@ from django.conf import settings
|
|||||||
from django.core.wsgi import get_wsgi_application
|
from django.core.wsgi import get_wsgi_application
|
||||||
|
|
||||||
# DEBUG 모드 아닐 때만 OpenTelemetry 활성
|
# DEBUG 모드 아닐 때만 OpenTelemetry 활성
|
||||||
|
print(f"[OTEL] DEBUG={settings.DEBUG}, TRACE_ENDPOINT={settings.TRACE_ENDPOINT}")
|
||||||
if not settings.DEBUG:
|
if not settings.DEBUG:
|
||||||
import grpc
|
import grpc
|
||||||
from opentelemetry import trace
|
from opentelemetry import trace
|
||||||
@ -41,13 +42,16 @@ if not settings.DEBUG:
|
|||||||
# TRACE_CA_CERT 설정에 따른 gRPC credentials 구성
|
# TRACE_CA_CERT 설정에 따른 gRPC credentials 구성
|
||||||
credentials = None
|
credentials = None
|
||||||
ca_cert_path = os.getenv('TRACE_CA_CERT', '').strip()
|
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):
|
if ca_cert_path and os.path.exists(ca_cert_path):
|
||||||
with open(ca_cert_path, 'rb') as f:
|
with open(ca_cert_path, 'rb') as f:
|
||||||
ca_cert = f.read()
|
ca_cert = f.read()
|
||||||
credentials = grpc.ssl_channel_credentials(root_certificates=ca_cert)
|
credentials = grpc.ssl_channel_credentials(root_certificates=ca_cert)
|
||||||
insecure = False
|
insecure = False
|
||||||
|
print(f"[OTEL] Using TLS with CA cert")
|
||||||
else:
|
else:
|
||||||
insecure = True
|
insecure = True
|
||||||
|
print(f"[OTEL] Using insecure mode")
|
||||||
|
|
||||||
otlp_exporter = OTLPSpanExporter(
|
otlp_exporter = OTLPSpanExporter(
|
||||||
endpoint=settings.TRACE_ENDPOINT,
|
endpoint=settings.TRACE_ENDPOINT,
|
||||||
@ -62,6 +66,7 @@ if not settings.DEBUG:
|
|||||||
trace.get_tracer_provider().add_span_processor(
|
trace.get_tracer_provider().add_span_processor(
|
||||||
BatchSpanProcessor(otlp_exporter)
|
BatchSpanProcessor(otlp_exporter)
|
||||||
)
|
)
|
||||||
|
print(f"[OTEL] OpenTelemetry initialized: service={settings.TRACE_SERVICE_NAME}, endpoint={settings.TRACE_ENDPOINT}")
|
||||||
|
|
||||||
# Django 요청/응답 추적
|
# Django 요청/응답 추적
|
||||||
DjangoInstrumentor().instrument()
|
DjangoInstrumentor().instrument()
|
||||||
|
|||||||
Reference in New Issue
Block a user