Upgrade Prometheus client

This commit is contained in:
Danilo Peixoto
2023-08-05 19:06:11 -03:00
committed by GitHub
parent 67938581d9
commit e6e92365d2
3 changed files with 11 additions and 6 deletions

View File

@@ -22,8 +22,12 @@ class Generator:
for name in dir(jupyterhub.metrics): for name in dir(jupyterhub.metrics):
obj = getattr(jupyterhub.metrics, name) obj = getattr(jupyterhub.metrics, name)
if obj.__class__.__module__.startswith('prometheus_client.'): if obj.__class__.__module__.startswith('prometheus_client.'):
for metric in obj.describe(): description = obj.describe()[0]
table_rows.append([metric.type, metric.name, metric.documentation]) table_rows.append([
description.type,
description.name,
description.documentation,
])
return table_rows return table_rows
def prometheus_metrics(self): def prometheus_metrics(self):

View File

@@ -11,14 +11,15 @@ from .utils import add_user, api_request, get_page
@pytest.mark.parametrize( @pytest.mark.parametrize(
"metric, expected_metric_name", "metric, expected_name",
[ [
(metrics.TOTAL_USERS, 'jupyterhub_total_users'), (metrics.TOTAL_USERS, 'jupyterhub_total_users'),
(metrics.REQUEST_DURATION_SECONDS, 'jupyterhub_request_duration_seconds'), (metrics.REQUEST_DURATION_SECONDS, 'jupyterhub_request_duration_seconds'),
], ],
) )
def test_metrics_prefix(metric, expected_metric_name): def test_metrics_prefix(metric, expected_name):
assert metric._name == expected_metric_name description = metric.describe()[0]
assert description.name == expected_name
async def test_total_users(app): async def test_total_users(app):

View File

@@ -7,7 +7,7 @@ jupyter_telemetry>=0.1.0
oauthlib>=3.0 oauthlib>=3.0
packaging packaging
pamela; sys_platform != 'win32' pamela; sys_platform != 'win32'
prometheus_client>=0.4.0 prometheus_client>=0.5.0
psutil>=5.6.5; sys_platform == 'win32' psutil>=5.6.5; sys_platform == 'win32'
python-dateutil python-dateutil
requests requests