From 7b93600973dd29091a2bc161d8785a47106b01d9 Mon Sep 17 00:00:00 2001 From: Swifty Date: Wed, 3 Dec 2025 11:04:38 +0100 Subject: [PATCH] fix duplicate promethues metrics --- .../backend/backend/monitoring/instrumentation.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/autogpt_platform/backend/backend/monitoring/instrumentation.py b/autogpt_platform/backend/backend/monitoring/instrumentation.py index 898324deaa..bd384b4ad2 100644 --- a/autogpt_platform/backend/backend/monitoring/instrumentation.py +++ b/autogpt_platform/backend/backend/monitoring/instrumentation.py @@ -143,6 +143,9 @@ def instrument_fastapi( ) # Create instrumentator with default metrics + # Use service-specific inprogress_name to avoid duplicate registration + # when multiple FastAPI apps are instrumented in the same process + service_subsystem = service_name.replace("-", "_") instrumentator = Instrumentator( should_group_status_codes=True, should_ignore_untemplated=True, @@ -150,7 +153,7 @@ def instrument_fastapi( should_instrument_requests_inprogress=True, excluded_handlers=excluded_handlers or ["/health", "/readiness"], env_var_name="ENABLE_METRICS", - inprogress_name="autogpt_http_requests_inprogress", + inprogress_name=f"autogpt_{service_subsystem}_http_requests_inprogress", inprogress_labels=True, )