From d78466507d53ea1676baaa275f5b2f15f5897222 Mon Sep 17 00:00:00 2001 From: Min RK Date: Wed, 18 Dec 2019 09:22:34 +0100 Subject: [PATCH] HUB_STARTUP_DURATION_SECONDS measures total startup time which is the main metric of interest for measuring disruptions due to restarts --- jupyterhub/app.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/jupyterhub/app.py b/jupyterhub/app.py index e3d0fcdb..eeb33cb4 100644 --- a/jupyterhub/app.py +++ b/jupyterhub/app.py @@ -2227,6 +2227,14 @@ class JupyterHub(Application): if self.generate_config or self.generate_certs or self.subapp: return self._start_future = asyncio.Future() + + def record_start(f): + startup_time = time.perf_counter() - hub_startup_start_time + self.log.debug("It took %.3f seconds for the Hub to start", startup_time) + HUB_STARTUP_DURATION_SECONDS.observe(startup_time) + + self._start_future.add_done_callback(record_start) + self.load_config_file(self.config_file) self.init_logging() self.log.info("Running JupyterHub version %s", jupyterhub.__version__) @@ -2305,10 +2313,6 @@ class JupyterHub(Application): init_spawners_future.add_done_callback(log_init_time) - HUB_STARTUP_DURATION_SECONDS.observe( - time.perf_counter() - hub_startup_start_time - ) - try: # don't allow a zero timeout because we still need to be sure