Skip to content

Commit d6edf6a

Browse files
dleenkevin-batesjtpio
authored
Allow users to opt out of prometheus metrics (#124)
* Allow users to opt out of prometheus metrics Poor mans fix for #123 * Update README.md Co-authored-by: Kevin Bates <[email protected]> * Lint README.md Co-authored-by: Kevin Bates <[email protected]> Co-authored-by: Jeremy Tuloup <[email protected]>
1 parent a5e6978 commit d6edf6a

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

README.md

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

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

96105
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)