File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change 58
58
"Jupyter Server Extensiom Version Information" ,
59
59
["name" , "version" , "enabled" ],
60
60
)
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
+ )
61
72
62
73
__all__ = [
63
74
"HTTP_REQUEST_DURATION_SECONDS" ,
Original file line number Diff line number Diff line change 110
110
GatewaySessionManager ,
111
111
)
112
112
from jupyter_server .log import log_request
113
- from jupyter_server .prometheus .metrics import SERVER_EXTENSION_INFO , SERVER_INFO
113
+ from jupyter_server .prometheus .metrics import (
114
+ ACTIVE_DURATION ,
115
+ LAST_ACTIVITY ,
116
+ SERVER_EXTENSION_INFO ,
117
+ SERVER_INFO ,
118
+ SERVER_STARTED ,
119
+ )
114
120
from jupyter_server .services .config import ConfigManager
115
121
from jupyter_server .services .contents .filemanager import (
116
122
AsyncFileContentsManager ,
@@ -2708,6 +2714,16 @@ def init_metrics(self) -> None:
2708
2714
name = ext .name , version = ext .version , enabled = str (ext .enabled ).lower ()
2709
2715
)
2710
2716
2717
+ started = self .web_app .settings ["started" ]
2718
+ SERVER_STARTED .set (started .timestamp ())
2719
+
2720
+ LAST_ACTIVITY .set_function (lambda : self .web_app .last_activity ().timestamp ())
2721
+ ACTIVE_DURATION .set_function (
2722
+ lambda : (
2723
+ self .web_app .last_activity () - self .web_app .settings ["started" ]
2724
+ ).total_seconds ()
2725
+ )
2726
+
2711
2727
@catch_config_error
2712
2728
def initialize (
2713
2729
self ,
You can’t perform that action at this time.
0 commit comments