diff --git a/edge/Dockerfile b/edge/Dockerfile index 586e613..ac53760 100644 --- a/edge/Dockerfile +++ b/edge/Dockerfile @@ -4,6 +4,7 @@ WORKDIR /app COPY requirements.txt ./ RUN pip install --no-cache-dir -r requirements.txt COPY src ./src +COPY gunicorn.conf.py ./ EXPOSE 5003 # Bind to $PORT when set (e.g. Cloud Run injects PORT=8080); default to 5003. diff --git a/edge/gunicorn.conf.py b/edge/gunicorn.conf.py new file mode 100644 index 0000000..1bcf053 --- /dev/null +++ b/edge/gunicorn.conf.py @@ -0,0 +1,22 @@ +"""Gunicorn settings: one access line per request on stdout, for Pantheos. + +Docker's json-file driver captures stdout and Pantheos ingests it, so each line +becomes a request log and feeds the container's rps / 5xx / p95. Monitoring +traffic (/metrics scrapes, /health checks) is left out so it doesn't drown the +real requests. +""" +from gunicorn import glogging + +accesslog = "-" +access_log_format = '"%(r)s" %(s)s %(M)sms' + +_QUIET_PATHS = ("/metrics", "/health") + + +class _Logger(glogging.Logger): + def access(self, resp, req, environ, request_time): + if req.path not in _QUIET_PATHS: + super().access(resp, req, environ, request_time) + + +logger_class = _Logger diff --git a/fetcher/Dockerfile b/fetcher/Dockerfile index 9a18930..cac5d35 100644 --- a/fetcher/Dockerfile +++ b/fetcher/Dockerfile @@ -5,6 +5,7 @@ COPY requirements.txt ./ RUN pip install --no-cache-dir -r requirements.txt COPY src ./src +COPY gunicorn.conf.py ./ RUN mkdir -p /app/data EXPOSE 5001 diff --git a/fetcher/gunicorn.conf.py b/fetcher/gunicorn.conf.py new file mode 100644 index 0000000..1bcf053 --- /dev/null +++ b/fetcher/gunicorn.conf.py @@ -0,0 +1,22 @@ +"""Gunicorn settings: one access line per request on stdout, for Pantheos. + +Docker's json-file driver captures stdout and Pantheos ingests it, so each line +becomes a request log and feeds the container's rps / 5xx / p95. Monitoring +traffic (/metrics scrapes, /health checks) is left out so it doesn't drown the +real requests. +""" +from gunicorn import glogging + +accesslog = "-" +access_log_format = '"%(r)s" %(s)s %(M)sms' + +_QUIET_PATHS = ("/metrics", "/health") + + +class _Logger(glogging.Logger): + def access(self, resp, req, environ, request_time): + if req.path not in _QUIET_PATHS: + super().access(resp, req, environ, request_time) + + +logger_class = _Logger diff --git a/generator/Dockerfile b/generator/Dockerfile index aa2532d..f0e5d61 100644 --- a/generator/Dockerfile +++ b/generator/Dockerfile @@ -17,6 +17,7 @@ COPY requirements.txt ./ RUN pip install --no-cache-dir -r requirements.txt COPY src ./src +COPY gunicorn.conf.py ./ RUN mkdir -p /app/src/static /app/data COPY --from=frontend-build /app/frontend/dist/ /app/src/static/ diff --git a/generator/gunicorn.conf.py b/generator/gunicorn.conf.py new file mode 100644 index 0000000..1bcf053 --- /dev/null +++ b/generator/gunicorn.conf.py @@ -0,0 +1,22 @@ +"""Gunicorn settings: one access line per request on stdout, for Pantheos. + +Docker's json-file driver captures stdout and Pantheos ingests it, so each line +becomes a request log and feeds the container's rps / 5xx / p95. Monitoring +traffic (/metrics scrapes, /health checks) is left out so it doesn't drown the +real requests. +""" +from gunicorn import glogging + +accesslog = "-" +access_log_format = '"%(r)s" %(s)s %(M)sms' + +_QUIET_PATHS = ("/metrics", "/health") + + +class _Logger(glogging.Logger): + def access(self, resp, req, environ, request_time): + if req.path not in _QUIET_PATHS: + super().access(resp, req, environ, request_time) + + +logger_class = _Logger