Add active_user_window configuration

This commit is contained in:
Daisuke Taniwaki
2018-06-06 19:00:34 +09:00
parent 784e5aa4ee
commit ac2590c679

View File

@@ -274,6 +274,9 @@ class JupyterHub(Application):
service_check_interval = Integer(60,
help="Interval (in seconds) at which to check connectivity of services with web endpoints."
).tag(config=True)
active_user_window = Integer(30 * 60,
help="Duration (in seconds) to determine the number of active users."
).tag(config=True)
data_files_path = Unicode(DATA_FILES_PATH,
help="The location of jupyterhub data files (e.g. /usr/local/share/jupyterhub)"
@@ -1786,8 +1789,7 @@ class JupyterHub(Application):
spawner.last_activity = max(spawner.last_activity, dt)
else:
spawner.last_activity = dt
# FIXME: Make this configurable duration. 30 minutes for now!
if (now - user.last_activity).total_seconds() < 30 * 60:
if (now - user.last_activity).total_seconds() < self.active_user_window:
active_users_count += 1
self.statsd.gauge('users.running', users_count)
self.statsd.gauge('users.active', active_users_count)