From aadc21a0013472d33254bf63c8e1deb7a1bd5428 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Tue, 19 Nov 2024 15:12:43 +0100 Subject: [PATCH] Add memory map profiling --- tilecloud_chain/server.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tilecloud_chain/server.py b/tilecloud_chain/server.py index bfc264157..d37e2be2f 100644 --- a/tilecloud_chain/server.py +++ b/tilecloud_chain/server.py @@ -44,7 +44,8 @@ import tilecloud.store.s3 from azure.core.exceptions import ResourceNotFoundError from c2cwsgiutils import health_check -from prometheus_client import Summary +from c2cwsgiutils.prometheus import MemoryMapCollector +from prometheus_client import REGISTRY, Summary from pyramid.config import Configurator from pyramid.httpexceptions import HTTPException, exception_response from pyramid.request import Request @@ -931,4 +932,8 @@ def main(global_config: Any, **settings: Any) -> Router: config.scan("tilecloud_chain.views") + if os.environ.get("TILECLOUD_CHAIN_PROMETHEUS_MEMORY_MAP", "false").lower() in ("true", "1", "on"): + REGISTRY.register(MemoryMapCollector("rss")) + REGISTRY.register(MemoryMapCollector("size")) + return config.make_wsgi_app()