diff --git a/infrastructure/backend/.env.template b/infrastructure/backend/.env.template index d5afaff..e494e5f 100644 --- a/infrastructure/backend/.env.template +++ b/infrastructure/backend/.env.template @@ -21,3 +21,7 @@ MINIO_ENDPOINT=minio:9000 MINIO_CUSTOM_ENDPOINT_URL=http://127.0.0.1:13244 MINIO_ACCESS_KEY=admin MINIO_SECRET_KEY=password + +OTEL_METRICS_EXPORTER=none +OTEL_EXPORTER_ZIPKIN_ENDPOINT=http://zipkin:9411/api/v2/spans +OTEL_TRACES_EXPORTER=zipkin_json diff --git a/services/backend/Dockerfile b/services/backend/Dockerfile index 8e95eb9..d899c1a 100644 --- a/services/backend/Dockerfile +++ b/services/backend/Dockerfile @@ -32,11 +32,12 @@ USER app ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 \ PYTHONOPTIMIZE=2 \ - PATH="/opt/venv/bin:$PATH" + PATH="/opt/venv/bin:$PATH" \ + DJANGO_SETTINGS_MODULE=config.settings EXPOSE 8080 HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --start-interval=2s --retries=3 \ CMD wget --no-verbose --tries=1 --spider http://127.0.0.1:8080/health?format=json || exit 1 -CMD [ "gunicorn", "config.wsgi", "--workers=8", "-b", "0.0.0.0:8080", "--access-logfile", "-", "--error-logfile", "-" ] +CMD [ "opentelemetry-instrument", "--service_name", "backend-django", "--traces_exporter", "zipkin_json", "gunicorn", "config.wsgi", "--workers=8", "-b", "0.0.0.0:8080", "--access-logfile", "-", "--error-logfile", "-" ] diff --git a/services/backend/pyproject.toml b/services/backend/pyproject.toml index 4501630..0e99640 100644 --- a/services/backend/pyproject.toml +++ b/services/backend/pyproject.toml @@ -15,6 +15,23 @@ dependencies = [ "django-stubs-ext>=5.1.3,<6.0.0", "gunicorn>=23.0.0,<24.0.0", "httpx>=0.28.1,<0.29.0", + "opentelemetry-api>=1.35.0", + "opentelemetry-distro>=0.56b0", + "opentelemetry-exporter-otlp>=1.35.0", + "opentelemetry-exporter-zipkin-proto-http>=1.11.1", + "opentelemetry-instrumentation-asyncio>=0.56b0", + "opentelemetry-instrumentation-celery>=0.56b0", + "opentelemetry-instrumentation-dbapi>=0.56b0", + "opentelemetry-instrumentation-django>=0.56b0", + "opentelemetry-instrumentation-httpx>=0.56b0", + "opentelemetry-instrumentation-psycopg2>=0.56b0", + "opentelemetry-instrumentation-requests>=0.56b0", + "opentelemetry-instrumentation-sqlite3>=0.56b0", + "opentelemetry-instrumentation-threading>=0.56b0", + "opentelemetry-instrumentation-urllib>=0.56b0", + "opentelemetry-instrumentation-urllib3>=0.56b0", + "opentelemetry-instrumentation-wsgi>=0.56b0", + "opentelemetry-sdk>=1.35.0", "pillow>=11.1.0,<12.0.0", "psycopg2-binary>=2.9.10,<3.0.0", "pydantic>=2.10.5,<3.0.0",