mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
fix(fastapi): use metrics in cases where PROMETHEUS_MULTIPROC_DIR is defined
Previously, we restricted this to gunicorn to get it working on aur-dev. This change makes it usable through any backend, and also no-op if PROMETHEUS_MULTIPROC_DIR is not defined. Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
cdb854259a
commit
9aa8decf40
3 changed files with 7 additions and 3 deletions
|
@ -209,9 +209,7 @@ async def index(request: Request):
|
|||
@router.get("/metrics")
|
||||
async def metrics(request: Request):
|
||||
registry = CollectorRegistry()
|
||||
if os.environ.get("FASTAPI_BACKEND", "") == "gunicorn": # pragma: no cover
|
||||
# This case only ever happens in production, when we are running
|
||||
# gunicorn. We don't test with gunicorn, so we don't cover this path.
|
||||
if os.environ.get("PROMETHEUS_MULTIPROC_DIR", None): # pragma: no cover
|
||||
multiprocess.MultiProcessCollector(registry)
|
||||
data = generate_latest(registry)
|
||||
headers = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue