Skip to content

Commit 2a39df8

Browse files
committed
Allow users to opt out of prometheus metrics
Poor mans fix for jupyter-server#123
1 parent 02c513d commit 2a39df8

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,13 @@ As a command line argument:
9191
jupyter notebook --ResourceUseDisplay.track_cpu_percent=True
9292
```
9393

94+
### Disable Prometheus Metrics
95+
There is a [known bug](https://github.com/jupyter-server/jupyter-resource-usage/issues/123) with Prometheus metrics which
96+
causes "lag"/pauses in the UI. To fix this you can disable Prometheus metric reporting using:
97+
```
98+
--ResourceUseDisplay.enable_prometheus_metrics=False
99+
```
100+
94101
## Resources Displayed
95102

96103
Currently the server extension only reports memory usage (just RSS) and CPU usage. Other metrics will be

jupyter_resource_usage/config.py

+7
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,10 @@ def _mem_limit_default(self):
122122
@default("cpu_limit")
123123
def _cpu_limit_default(self):
124124
return float(os.environ.get("CPU_LIMIT", 0))
125+
126+
enable_prometheus_metrics = Bool(
127+
default_value=True,
128+
help="""
129+
Set to False in order to disable reporting of Prometheus style metrics.
130+
""",
131+
).tag(config=True)

jupyter_resource_usage/server_extension.py

+9-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ def load_jupyter_server_extension(server_app):
1919
".*", [(url_path_join(base_url, "/api/metrics/v1"), ApiHandler)]
2020
)
2121

22-
callback = ioloop.PeriodicCallback(
23-
PrometheusHandler(PSUtilMetricsLoader(server_app)), 1000
24-
)
25-
callback.start()
22+
if resuseconfig.enable_prometheus_metrics:
23+
callback = ioloop.PeriodicCallback(
24+
PrometheusHandler(PSUtilMetricsLoader(server_app)), 1000
25+
)
26+
callback.start()
27+
else:
28+
server_app.log.info(
29+
"Prometheus metrics reporting disabled in jupyter_resource_usage."
30+
)

0 commit comments

Comments
 (0)