From e951fab0db264d5b561a027cedfc8a151484bd60 Mon Sep 17 00:00:00 2001 From: Maxim Vov Date: Thu, 27 Sep 2018 01:55:52 +0300 Subject: [PATCH] Added docs to the prometheus package and the terminal.api_handlers file. --- notebook/prometheus/__init__.py | 4 ++++ notebook/terminal/api_handlers.py | 3 +++ 2 files changed, 7 insertions(+) diff --git a/notebook/prometheus/__init__.py b/notebook/prometheus/__init__.py index e69de29bb..c63c130a1 100644 --- a/notebook/prometheus/__init__.py +++ b/notebook/prometheus/__init__.py @@ -0,0 +1,4 @@ +""" +A package containing all the functionality and +configuration connected to the prometheus metrics +""" \ No newline at end of file diff --git a/notebook/terminal/api_handlers.py b/notebook/terminal/api_handlers.py index 54d324757..6147ce075 100644 --- a/notebook/terminal/api_handlers.py +++ b/notebook/terminal/api_handlers.py @@ -10,6 +10,7 @@ class TerminalRootHandler(APIHandler): tm = self.terminal_manager terms = [{'name': name} for name in tm.terminals] self.finish(json.dumps(terms)) + # Update the metric below to the length of the list 'terms' TERMINAL_CURRENTLY_RUNNING_TOTAL.set( len(terms) ) @@ -19,6 +20,7 @@ class TerminalRootHandler(APIHandler): """POST /terminals creates a new terminal and redirects to it""" name, _ = self.terminal_manager.new_named_terminal() self.finish(json.dumps({'name': name})) + # Increase the metric by one because a new terminal was created TERMINAL_CURRENTLY_RUNNING_TOTAL.inc() @@ -41,6 +43,7 @@ class TerminalHandler(APIHandler): yield tm.terminate(name, force=True) self.set_status(204) self.finish() + # Decrease the metric below by one because a terminal has been shutdown TERMINAL_CURRENTLY_RUNNING_TOTAL.dec(1) else: raise web.HTTPError(404, "Terminal not found: %r" % name)