diff --git a/docs/generate-metrics.py b/docs/generate-metrics.py index 97ea0322..00551380 100644 --- a/docs/generate-metrics.py +++ b/docs/generate-metrics.py @@ -22,14 +22,8 @@ class Generator: for name in dir(jupyterhub.metrics): obj = getattr(jupyterhub.metrics, name) if obj.__class__.__module__.startswith('prometheus_client.'): - description = obj.describe()[0] - table_rows.append( - [ - description.type, - description.name, - description.documentation, - ] - ) + for metric in obj.describe(): + table_rows.append([metric.type, metric.name, metric.documentation]) return table_rows def prometheus_metrics(self): diff --git a/jupyterhub/tests/test_metrics.py b/jupyterhub/tests/test_metrics.py index 94289be6..831c81ac 100644 --- a/jupyterhub/tests/test_metrics.py +++ b/jupyterhub/tests/test_metrics.py @@ -11,15 +11,15 @@ from .utils import add_user, api_request, get_page @pytest.mark.parametrize( - "metric, expected_name", + "metric_object, expected_names", [ - (metrics.TOTAL_USERS, 'jupyterhub_total_users'), - (metrics.REQUEST_DURATION_SECONDS, 'jupyterhub_request_duration_seconds'), + (metrics.TOTAL_USERS, ['jupyterhub_total_users']), + (metrics.REQUEST_DURATION_SECONDS, ['jupyterhub_request_duration_seconds']), ], ) -def test_metrics_prefix(metric, expected_name): - description = metric.describe()[0] - assert description.name == expected_name +def test_metrics_prefix(metric_object, expected_names): + for metric, expected_name in zip(metric_obj.describe(), expected_names): + assert metric.name == expected_name async def test_total_users(app):