mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-08 10:34:10 +00:00
Add prometheus metric to measure hub startup time (#2799)
Add prometheus metric to measure hub startup time
This commit is contained in:
@@ -85,6 +85,8 @@ from .utils import (
|
|||||||
print_ps_info,
|
print_ps_info,
|
||||||
make_ssl_context,
|
make_ssl_context,
|
||||||
)
|
)
|
||||||
|
from .metrics import HUB_STARTUP_DURATION_SECONDS
|
||||||
|
from .metrics import INIT_SPAWNERS_DURATION_SECONDS
|
||||||
from .metrics import RUNNING_SERVERS
|
from .metrics import RUNNING_SERVERS
|
||||||
from .metrics import TOTAL_USERS
|
from .metrics import TOTAL_USERS
|
||||||
|
|
||||||
@@ -2220,6 +2222,7 @@ class JupyterHub(Application):
|
|||||||
|
|
||||||
@catch_config_error
|
@catch_config_error
|
||||||
async def initialize(self, *args, **kwargs):
|
async def initialize(self, *args, **kwargs):
|
||||||
|
hub_startup_start_time = time.perf_counter()
|
||||||
super().initialize(*args, **kwargs)
|
super().initialize(*args, **kwargs)
|
||||||
if self.generate_config or self.generate_certs or self.subapp:
|
if self.generate_config or self.generate_certs or self.subapp:
|
||||||
return
|
return
|
||||||
@@ -2292,14 +2295,20 @@ class JupyterHub(Application):
|
|||||||
|
|
||||||
def log_init_time(f):
|
def log_init_time(f):
|
||||||
n_spawners = f.result()
|
n_spawners = f.result()
|
||||||
|
spawner_initialization_time = time.perf_counter() - init_start_time
|
||||||
|
INIT_SPAWNERS_DURATION_SECONDS.observe(spawner_initialization_time)
|
||||||
self.log.info(
|
self.log.info(
|
||||||
"Initialized %i spawners in %.3f seconds",
|
"Initialized %i spawners in %.3f seconds",
|
||||||
n_spawners,
|
n_spawners,
|
||||||
time.perf_counter() - init_start_time,
|
spawner_initialization_time,
|
||||||
)
|
)
|
||||||
|
|
||||||
init_spawners_future.add_done_callback(log_init_time)
|
init_spawners_future.add_done_callback(log_init_time)
|
||||||
|
|
||||||
|
HUB_STARTUP_DURATION_SECONDS.observe(
|
||||||
|
time.perf_counter() - hub_startup_start_time
|
||||||
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
# don't allow a zero timeout because we still need to be sure
|
# don't allow a zero timeout because we still need to be sure
|
||||||
|
@@ -45,6 +45,14 @@ CHECK_ROUTES_DURATION_SECONDS = Histogram(
|
|||||||
'check_routes_duration_seconds', 'Time taken to validate all routes in proxy'
|
'check_routes_duration_seconds', 'Time taken to validate all routes in proxy'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
HUB_STARTUP_DURATION_SECONDS = Histogram(
|
||||||
|
'hub_startup_duration_seconds', 'Time taken for Hub to start'
|
||||||
|
)
|
||||||
|
|
||||||
|
INIT_SPAWNERS_DURATION_SECONDS = Histogram(
|
||||||
|
'init_spawners_duration_seconds', 'Time taken for spawners to initialize'
|
||||||
|
)
|
||||||
|
|
||||||
PROXY_POLL_DURATION_SECONDS = Histogram(
|
PROXY_POLL_DURATION_SECONDS = Histogram(
|
||||||
'proxy_poll_duration_seconds', 'duration for polling all routes from proxy'
|
'proxy_poll_duration_seconds', 'duration for polling all routes from proxy'
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user