Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Nov 4, 2024
1 parent 5b157ca commit a992d31
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
14 changes: 11 additions & 3 deletions jupyter_server/prometheus/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,17 @@
"Jupyter Server Extensiom Version Information",
["name", "version", "enabled"],
)
LAST_ACTIVITY = Gauge("jupyter_server_last_activity_timestamp_seconds", "Timestamp of last seen activity on this Jupyter Server")
SERVER_STARTED = Gauge("jupyter_server_started_timestamp_seconds", "Timestamp of when this Jupyter Server was started")
ACTIVE_DURATION = Gauge("jupyter_server_active_duration_seconds", "Number of seconds this Jupyter Server has been active")
LAST_ACTIVITY = Gauge(
"jupyter_server_last_activity_timestamp_seconds",
"Timestamp of last seen activity on this Jupyter Server",
)
SERVER_STARTED = Gauge(
"jupyter_server_started_timestamp_seconds", "Timestamp of when this Jupyter Server was started"
)
ACTIVE_DURATION = Gauge(
"jupyter_server_active_duration_seconds",
"Number of seconds this Jupyter Server has been active",
)

__all__ = [
"HTTP_REQUEST_DURATION_SECONDS",
Expand Down
14 changes: 12 additions & 2 deletions jupyter_server/serverapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,13 @@
GatewaySessionManager,
)
from jupyter_server.log import log_request
from jupyter_server.prometheus.metrics import SERVER_EXTENSION_INFO, SERVER_INFO, SERVER_STARTED, LAST_ACTIVITY, ACTIVE_DURATION
from jupyter_server.prometheus.metrics import (
ACTIVE_DURATION,
LAST_ACTIVITY,
SERVER_EXTENSION_INFO,
SERVER_INFO,
SERVER_STARTED,
)
from jupyter_server.services.config import ConfigManager
from jupyter_server.services.contents.filemanager import (
AsyncFileContentsManager,
Expand Down Expand Up @@ -2712,7 +2718,11 @@ def init_metrics(self) -> None:
SERVER_STARTED.set(started.timestamp())

LAST_ACTIVITY.set_function(lambda: self.web_app.last_activity().timestamp())
ACTIVE_DURATION.set_function(lambda: (self.web_app.last_activity() - self.web_app.settings["started"]).total_seconds())
ACTIVE_DURATION.set_function(
lambda: (
self.web_app.last_activity() - self.web_app.settings["started"]
).total_seconds()
)

@catch_config_error
def initialize(
Expand Down

0 comments on commit a992d31

Please sign in to comment.