Skip to content

Commit a992d31

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 5b157ca commit a992d31

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

jupyter_server/prometheus/metrics.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,17 @@
5858
"Jupyter Server Extensiom Version Information",
5959
["name", "version", "enabled"],
6060
)
61-
LAST_ACTIVITY = Gauge("jupyter_server_last_activity_timestamp_seconds", "Timestamp of last seen activity on this Jupyter Server")
62-
SERVER_STARTED = Gauge("jupyter_server_started_timestamp_seconds", "Timestamp of when this Jupyter Server was started")
63-
ACTIVE_DURATION = Gauge("jupyter_server_active_duration_seconds", "Number of seconds this Jupyter Server has been active")
61+
LAST_ACTIVITY = Gauge(
62+
"jupyter_server_last_activity_timestamp_seconds",
63+
"Timestamp of last seen activity on this Jupyter Server",
64+
)
65+
SERVER_STARTED = Gauge(
66+
"jupyter_server_started_timestamp_seconds", "Timestamp of when this Jupyter Server was started"
67+
)
68+
ACTIVE_DURATION = Gauge(
69+
"jupyter_server_active_duration_seconds",
70+
"Number of seconds this Jupyter Server has been active",
71+
)
6472

6573
__all__ = [
6674
"HTTP_REQUEST_DURATION_SECONDS",

jupyter_server/serverapp.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,13 @@
110110
GatewaySessionManager,
111111
)
112112
from jupyter_server.log import log_request
113-
from jupyter_server.prometheus.metrics import SERVER_EXTENSION_INFO, SERVER_INFO, SERVER_STARTED, LAST_ACTIVITY, ACTIVE_DURATION
113+
from jupyter_server.prometheus.metrics import (
114+
ACTIVE_DURATION,
115+
LAST_ACTIVITY,
116+
SERVER_EXTENSION_INFO,
117+
SERVER_INFO,
118+
SERVER_STARTED,
119+
)
114120
from jupyter_server.services.config import ConfigManager
115121
from jupyter_server.services.contents.filemanager import (
116122
AsyncFileContentsManager,
@@ -2712,7 +2718,11 @@ def init_metrics(self) -> None:
27122718
SERVER_STARTED.set(started.timestamp())
27132719

27142720
LAST_ACTIVITY.set_function(lambda: self.web_app.last_activity().timestamp())
2715-
ACTIVE_DURATION.set_function(lambda: (self.web_app.last_activity() - self.web_app.settings["started"]).total_seconds())
2721+
ACTIVE_DURATION.set_function(
2722+
lambda: (
2723+
self.web_app.last_activity() - self.web_app.settings["started"]
2724+
).total_seconds()
2725+
)
27162726

27172727
@catch_config_error
27182728
def initialize(

0 commit comments

Comments
 (0)