fixed running_servers count

This commit is contained in:
GeorgianaElena
2019-07-04 13:23:32 +03:00
parent 276ef26161
commit 97c27774b1
3 changed files with 5 additions and 5 deletions

View File

@@ -759,6 +759,7 @@ class BaseHandler(RequestHandler):
active_counts['spawn_pending'] + active_counts['proxy_pending']
)
active_count = active_counts['active']
RUNNING_SERVERS.set(active_count)
concurrent_spawn_limit = self.concurrent_spawn_limit
active_server_limit = self.active_server_limit
@@ -842,7 +843,6 @@ class BaseHandler(RequestHandler):
"User %s took %.3f seconds to start", user_server_name, toc - tic
)
self.statsd.timing('spawner.success', (toc - tic) * 1000)
RUNNING_SERVERS.inc()
SERVER_SPAWN_DURATION_SECONDS.labels(
status=ServerSpawnStatus.success
).observe(time.perf_counter() - spawn_start_time)
@@ -854,6 +854,7 @@ class BaseHandler(RequestHandler):
PROXY_ADD_DURATION_SECONDS.labels(status='success').observe(
time.perf_counter() - proxy_add_start_time
)
RUNNING_SERVERS.inc()
except Exception:
self.log.exception("Failed to add %s to proxy!", user_server_name)
self.log.error(
@@ -1022,7 +1023,6 @@ class BaseHandler(RequestHandler):
"User %s server took %.3f seconds to stop", user.name, toc - tic
)
self.statsd.timing('spawner.stop', (toc - tic) * 1000)
RUNNING_SERVERS.dec()
SERVER_STOP_DURATION_SECONDS.labels(
status=ServerStopStatus.success
).observe(toc - tic)

View File

@@ -39,9 +39,7 @@ RUNNING_SERVERS = Gauge(
'running_servers', 'the number of user servers currently running'
)
RUNNING_SERVERS.set(0)
TOTAL_USERS = Gauge('total_users', 'toal number of users')
TOTAL_USERS = Gauge('total_users', 'total number of users')
TOTAL_USERS.set(0)

View File

@@ -21,6 +21,7 @@ from .crypto import decrypt
from .crypto import encrypt
from .crypto import EncryptionUnavailable
from .crypto import InvalidToken
from .metrics import RUNNING_SERVERS
from .metrics import TOTAL_USERS
from .objects import Server
from .spawner import LocalProcessSpawner
@@ -753,6 +754,7 @@ class User:
self.db.delete(oauth_client)
self.db.commit()
self.log.debug("Finished stopping %s", spawner._log_name)
RUNNING_SERVERS.dec()
finally:
spawner.orm_spawner.started = None
self.db.commit()