Skip to content

Commit

Permalink
Add prometheus info metrics listing server extensions + versions
Browse files Browse the repository at this point in the history
Follow-up to #1467.
  • Loading branch information
yuvipanda committed Nov 4, 2024
1 parent 32679b9 commit 3bb172a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions jupyter_server/prometheus/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@

# New prometheus metrics that do not exist in notebook v6 go here
SERVER_INFO = Info("jupyter_server", "Jupyter Server Version information")
SERVER_EXTENSION_INFO = Info("jupyter_server_extension", "Jupyter Server Extensiom Version Information", ["extension_name", "package_name", "version", "enabled"])

__all__ = [
"HTTP_REQUEST_DURATION_SECONDS",
Expand Down
10 changes: 9 additions & 1 deletion jupyter_server/serverapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
GatewaySessionManager,
)
from jupyter_server.log import log_request
from jupyter_server.prometheus.metrics import SERVER_INFO
from jupyter_server.prometheus.metrics import SERVER_INFO, SERVER_EXTENSION_INFO
from jupyter_server.services.config import ConfigManager
from jupyter_server.services.contents.filemanager import (
AsyncFileContentsManager,
Expand Down Expand Up @@ -2703,6 +2703,14 @@ def init_metrics(self) -> None:
"""
SERVER_INFO.info({"version": __version__})

for k, ext in self.extension_manager.extensions.items():
SERVER_EXTENSION_INFO.labels(
package_name=k,
extension_name=ext.name,
version=ext.version,
enabled=str(ext.enabled).lower()
)

@catch_config_error
def initialize(
self,
Expand Down

0 comments on commit 3bb172a

Please sign in to comment.