mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-15 22:13:00 +00:00
Issue #13 Outreachy: add running_servers metric
This commit is contained in:
@@ -31,6 +31,7 @@ from ..utils import maybe_future, url_path_join
|
||||
from ..metrics import (
|
||||
SERVER_SPAWN_DURATION_SECONDS, ServerSpawnStatus,
|
||||
PROXY_ADD_DURATION_SECONDS, ProxyAddStatus,
|
||||
CURRENTLY_RUNNING_SERVERS
|
||||
)
|
||||
|
||||
# pattern for the authentication token header
|
||||
@@ -729,6 +730,7 @@ class BaseHandler(RequestHandler):
|
||||
toc = IOLoop.current().time()
|
||||
self.log.info("User %s took %.3f seconds to start", user_server_name, toc-tic)
|
||||
self.statsd.timing('spawner.success', (toc - tic) * 1000)
|
||||
CURRENTLY_RUNNING_SERVERS.inc()
|
||||
SERVER_SPAWN_DURATION_SECONDS.labels(
|
||||
status=ServerSpawnStatus.success
|
||||
).observe(time.perf_counter() - spawn_start_time)
|
||||
@@ -880,6 +882,7 @@ class BaseHandler(RequestHandler):
|
||||
toc = IOLoop.current().time()
|
||||
self.log.info("User %s server took %.3f seconds to stop", user.name, toc - tic)
|
||||
self.statsd.timing('spawner.stop', (toc - tic) * 1000)
|
||||
CURRENTLY_RUNNING_SERVERS.dec()
|
||||
|
||||
try:
|
||||
await gen.with_timeout(timedelta(seconds=self.slow_stop_timeout), stop())
|
||||
|
@@ -18,6 +18,7 @@ them manually here.
|
||||
from enum import Enum
|
||||
|
||||
from prometheus_client import Histogram
|
||||
from prometheus_client import Gauge
|
||||
|
||||
REQUEST_DURATION_SECONDS = Histogram(
|
||||
'request_duration_seconds',
|
||||
@@ -34,6 +35,13 @@ SERVER_SPAWN_DURATION_SECONDS = Histogram(
|
||||
buckets=[0.5, 1, 2.5, 5, 10, 15, 30, 60, 120, float("inf")]
|
||||
)
|
||||
|
||||
CURRENTLY_RUNNING_SERVERS = Gauge(
|
||||
'currently_running_servers',
|
||||
'the number of user servers currently running',
|
||||
)
|
||||
|
||||
CURRENTLY_RUNNING_SERVERS.set(0)
|
||||
|
||||
class ServerSpawnStatus(Enum):
|
||||
"""
|
||||
Possible values for 'status' label of SERVER_SPAWN_DURATION_SECONDS
|
||||
|
Reference in New Issue
Block a user