From eee642dda05515166ba11d8277ec815d9427ea8b Mon Sep 17 00:00:00 2001 From: Vidar Tonaas Fauske Date: Thu, 26 Sep 2019 11:02:38 +0100 Subject: [PATCH 1/2] Update metrics.py I think this fixes an incorrect import? --- jupyter_server/metrics.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jupyter_server/metrics.py b/jupyter_server/metrics.py index a67a252ade..9f46951056 100644 --- a/jupyter_server/metrics.py +++ b/jupyter_server/metrics.py @@ -1,4 +1,4 @@ -from ..prometheus.metrics import HTTP_REQUEST_DURATION_SECONDS +from .prometheus.metrics import HTTP_REQUEST_DURATION_SECONDS def prometheus_log_method(handler): From 0c05748d6c86cba460be9c6b103f3a2910f918d8 Mon Sep 17 00:00:00 2001 From: Vidar Tonaas Fauske Date: Thu, 26 Sep 2019 16:21:13 +0100 Subject: [PATCH 2/2] Cleanup metrics --- jupyter_server/metrics.py | 24 ---------------------- jupyter_server/prometheus/log_functions.py | 2 +- 2 files changed, 1 insertion(+), 25 deletions(-) delete mode 100644 jupyter_server/metrics.py diff --git a/jupyter_server/metrics.py b/jupyter_server/metrics.py deleted file mode 100644 index 9f46951056..0000000000 --- a/jupyter_server/metrics.py +++ /dev/null @@ -1,24 +0,0 @@ -from .prometheus.metrics import HTTP_REQUEST_DURATION_SECONDS - - -def prometheus_log_method(handler): - """ - Tornado log handler for recording RED metrics. - - We record the following metrics: - Rate - the number of requests, per second, your services are serving. - Errors - the number of failed requests per second. - Duration - The amount of time each request takes expressed as a time interval. - - We use a fully qualified name of the handler as a label, - rather than every url path to reduce cardinality. - - This function should be either the value of or called from a function - that is the 'log_function' tornado setting. This makes it get called - at the end of every request, allowing us to record the metrics we need. - """ - HTTP_REQUEST_DURATION_SECONDS.labels( - method=handler.request.method, - handler='{}.{}'.format(handler.__class__.__module__, type(handler).__name__), - status_code=handler.get_status() - ).observe(handler.request.request_time()) diff --git a/jupyter_server/prometheus/log_functions.py b/jupyter_server/prometheus/log_functions.py index 548c5fd8d4..6f13fc6eb8 100644 --- a/jupyter_server/prometheus/log_functions.py +++ b/jupyter_server/prometheus/log_functions.py @@ -1,4 +1,4 @@ -from jupyter_server.prometheus.metrics import HTTP_REQUEST_DURATION_SECONDS +from .metrics import HTTP_REQUEST_DURATION_SECONDS def prometheus_log_method(handler):