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 5858 "Jupyter Server Extensiom Version Information" ,
5959 ["name" , "version" , "enabled" ],
6060)
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+ )
6172
6273__all__ = [
6374 "HTTP_REQUEST_DURATION_SECONDS" ,
Original file line number Diff line number Diff line change 110110 GatewaySessionManager ,
111111)
112112from 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+ )
114120from jupyter_server .services .config import ConfigManager
115121from jupyter_server .services .contents .filemanager import (
116122 AsyncFileContentsManager ,
@@ -2708,6 +2714,16 @@ def init_metrics(self) -> None:
27082714 name = ext .name , version = ext .version , enabled = str (ext .enabled ).lower ()
27092715 )
27102716
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+
27112727 @catch_config_error
27122728 def initialize (
27132729 self ,
You can’t perform that action at this time.
0 commit comments