From 7b946b1182aecc02dd2f5a5e9631ee4e8ae90937 Mon Sep 17 00:00:00 2001 From: devops Date: Thu, 17 Sep 2026 02:52:47 +0000 Subject: [PATCH] OpenTelemetry tracing add (default off, k8s me on) --- Dockerfile | 10 +++++++++- requirements.txt | 7 +++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3b74726..6c15942 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,4 +22,12 @@ USER appuser EXPOSE 8000 HEALTHCHECK --interval=30s --timeout=3s CMD python -c "import urllib.request;urllib.request.urlopen('http://127.0.0.1:8000/health')" -CMD ["gunicorn", "--bind", "0.0.0.0:8000", "--workers", "2", "app.main:app"] +# Tracing default OFF. k8s manifest me OTEL_SDK_DISABLED=false karke on hota hai, +# taaki build/smoke test ke waqt export ki koshish na ho. +ENV OTEL_SDK_DISABLED=true \ + OTEL_TRACES_EXPORTER=otlp \ + OTEL_METRICS_EXPORTER=none \ + OTEL_LOGS_EXPORTER=none \ + OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf + +CMD ["opentelemetry-instrument", "gunicorn", "--bind", "0.0.0.0:8000", "--workers", "2", "app.main:app"] diff --git a/requirements.txt b/requirements.txt index b733f8f..2c79a47 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,5 @@ -flask==3.0.3 -gunicorn==22.0.0 +flask +gunicorn +opentelemetry-distro +opentelemetry-exporter-otlp-proto-http +opentelemetry-instrumentation-flask