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 jupyter-server#123
  • Loading branch information
dleen committed Apr 6, 2022
1 parent dd49608 commit 8956674
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
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)
9 changes: 5 additions & 4 deletions jupyter_resource_usage/server_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ 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()

0 comments on commit 8956674

Please sign in to comment.