Skip to content

Commit

Permalink
Allow users to opt out of prometheus metrics
Browse files Browse the repository at this point in the history
Poor mans fix for #123
  • Loading branch information
dleen committed Aug 22, 2022
1 parent dd49608 commit 8c5d477
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ As a command line argument:
jupyter notebook --ResourceUseDisplay.track_cpu_percent=True
```

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

## Resources Displayed

Currently the server extension only reports memory usage (just RSS) and CPU usage. Other metrics will be
Expand Down
7 changes: 7 additions & 0 deletions jupyter_resource_usage/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,10 @@ def _mem_limit_default(self):
@default("cpu_limit")
def _cpu_limit_default(self):
return float(os.environ.get("CPU_LIMIT", 0))

enable_prometheus_metrics = Bool(
default_value=True,
help="""
Set to False in order to disable reporting of Prometheus style metrics.
""",
).tag(config=True)
11 changes: 7 additions & 4 deletions jupyter_resource_usage/server_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ def load_jupyter_server_extension(server_app):
".*", [(url_path_join(base_url, "/api/metrics/v1"), ApiHandler)]
)

callback = ioloop.PeriodicCallback(
PrometheusHandler(PSUtilMetricsLoader(server_app)), 1000
)
callback.start()
if resuseconfig.enable_prometheus_metrics:
callback = ioloop.PeriodicCallback(
PrometheusHandler(PSUtilMetricsLoader(server_app)), 1000
)
callback.start()
else:
server_app.log.info("Prometheus metrics reporting disabled in jupyter_resource_usage.")

0 comments on commit 8c5d477

Please sign in to comment.