From a0fdef254eb976edabb991a977a251d35c652ccd Mon Sep 17 00:00:00 2001 From: Anthony Mahanna Date: Fri, 29 Dec 2023 21:02:01 -0500 Subject: [PATCH 1/4] update metrics endpoint to `v2` --- arango/database.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arango/database.py b/arango/database.py index e33bd5ae..ef64c7e5 100644 --- a/arango/database.py +++ b/arango/database.py @@ -838,7 +838,7 @@ def metrics(self) -> Result[str]: :return: Server metrics in Prometheus format. :rtype: str """ - request = Request(method="get", endpoint="/_admin/metrics") + request = Request(method="get", endpoint="/_admin/metrics/v2") def response_handler(resp: Response) -> str: if resp.is_success: From de92c0943df07956cd1a97d90814bb22f149118b Mon Sep 17 00:00:00 2001 From: Anthony Mahanna Date: Thu, 25 Jan 2024 09:40:01 -0500 Subject: [PATCH 2/4] add `metrics` warning --- arango/database.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arango/database.py b/arango/database.py index ef64c7e5..a72e6034 100644 --- a/arango/database.py +++ b/arango/database.py @@ -11,6 +11,8 @@ from typing import Any, List, Optional, Sequence, Union from warnings import warn +from packaging import version + from arango.api import ApiGroup from arango.aql import AQL from arango.backup import Backup @@ -838,6 +840,10 @@ def metrics(self) -> Result[str]: :return: Server metrics in Prometheus format. :rtype: str """ + if version.parse(self.version()) < version.parse("3.10"): + m = "You are using the Metrics V2 API with a database version less than 3.10. The old metrics format is not available anymore." # noqa: E501 + warn(m, DeprecationWarning, stacklevel=2) + request = Request(method="get", endpoint="/_admin/metrics/v2") def response_handler(resp: Response) -> str: From cf2360c55b29822583cdc302204c2708e5ce855b Mon Sep 17 00:00:00 2001 From: Anthony Mahanna Date: Thu, 25 Jan 2024 09:43:48 -0500 Subject: [PATCH 3/4] fix lint --- arango/database.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arango/database.py b/arango/database.py index a72e6034..cf790aa2 100644 --- a/arango/database.py +++ b/arango/database.py @@ -840,7 +840,8 @@ def metrics(self) -> Result[str]: :return: Server metrics in Prometheus format. :rtype: str """ - if version.parse(self.version()) < version.parse("3.10"): + db_version: str = str(self.version()).split("-")[0] + if version.parse(db_version) < version.parse("3.10"): m = "You are using the Metrics V2 API with a database version less than 3.10. The old metrics format is not available anymore." # noqa: E501 warn(m, DeprecationWarning, stacklevel=2) From 5aeaf03a1f024db4ce767bbf52f0fd50e88dc1f1 Mon Sep 17 00:00:00 2001 From: Anthony Mahanna Date: Thu, 25 Jan 2024 09:47:16 -0500 Subject: [PATCH 4/4] remove version check --- arango/database.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/arango/database.py b/arango/database.py index cf790aa2..ef64c7e5 100644 --- a/arango/database.py +++ b/arango/database.py @@ -11,8 +11,6 @@ from typing import Any, List, Optional, Sequence, Union from warnings import warn -from packaging import version - from arango.api import ApiGroup from arango.aql import AQL from arango.backup import Backup @@ -840,11 +838,6 @@ def metrics(self) -> Result[str]: :return: Server metrics in Prometheus format. :rtype: str """ - db_version: str = str(self.version()).split("-")[0] - if version.parse(db_version) < version.parse("3.10"): - m = "You are using the Metrics V2 API with a database version less than 3.10. The old metrics format is not available anymore." # noqa: E501 - warn(m, DeprecationWarning, stacklevel=2) - request = Request(method="get", endpoint="/_admin/metrics/v2") def response_handler(resp: Response) -> str: