From 7293e10a640a81851b0f3b12493f55f0f03114f7 Mon Sep 17 00:00:00 2001 From: Jennifer Richards Date: Mon, 4 Nov 2024 16:46:23 +0000 Subject: [PATCH] feat: log start of gunicorn request (#8154) * feat: log start of gunicorn request * feat: add query string --- dev/build/gunicorn.conf.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/dev/build/gunicorn.conf.py b/dev/build/gunicorn.conf.py index 48661ef77..89d3dd58d 100644 --- a/dev/build/gunicorn.conf.py +++ b/dev/build/gunicorn.conf.py @@ -47,3 +47,18 @@ logconfig_dict = { } } } + +def pre_request(worker, req): + client_ip = "-" + cf_ray = "-" + for (header, value) in req.headers: + header = header.lower() + if header == "cf-connecting-ip": + client_ip = value + elif header == "cf-ray": + cf_ray = value + if req.query: + path = f"{req.path}?{req.query}" + else: + path = req.path + worker.log.info(f"gunicorn starting to process {req.method} {path} (client_ip={client_ip}, cf_ray={cf_ray})")