mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-16 14:33:00 +00:00
Add eventlogging infrastructure
- Introduce the EventLog class from BinderHub for emitting structured event data - Instrument server starts and stops to emit events - Defaults to not saving any events anywhere
This commit is contained in:
@@ -156,6 +156,10 @@ class BaseHandler(RequestHandler):
|
||||
def oauth_provider(self):
|
||||
return self.settings['oauth_provider']
|
||||
|
||||
@property
|
||||
def event_log(self):
|
||||
return self.settings['event_log']
|
||||
|
||||
def finish(self, *args, **kwargs):
|
||||
"""Roll back any uncommitted transactions from the handler."""
|
||||
if self.db.dirty:
|
||||
@@ -846,6 +850,11 @@ class BaseHandler(RequestHandler):
|
||||
SERVER_SPAWN_DURATION_SECONDS.labels(
|
||||
status=ServerSpawnStatus.success
|
||||
).observe(time.perf_counter() - spawn_start_time)
|
||||
self.event_log.emit('hub.jupyter.org/server-action', 1, {
|
||||
'action': 'start',
|
||||
'username': user.name,
|
||||
'servername': server_name
|
||||
})
|
||||
proxy_add_start_time = time.perf_counter()
|
||||
spawner._proxy_pending = True
|
||||
try:
|
||||
@@ -1026,6 +1035,11 @@ class BaseHandler(RequestHandler):
|
||||
SERVER_STOP_DURATION_SECONDS.labels(
|
||||
status=ServerStopStatus.success
|
||||
).observe(toc - tic)
|
||||
self.event_log.emit('hub.jupyter.org/server-action', 1, {
|
||||
'action': 'stop',
|
||||
'username': user.name,
|
||||
'servername': server_name
|
||||
})
|
||||
except:
|
||||
SERVER_STOP_DURATION_SECONDS.labels(
|
||||
status=ServerStopStatus.failure
|
||||
|
Reference in New Issue
Block a user