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()