From 39f39c50112aa0afc392f652643d24c2233bab30 Mon Sep 17 00:00:00 2001 From: eadakie Date: Fri, 8 Aug 2025 10:55:56 +0100 Subject: [PATCH] [IDUN-129935]Removed unused failure metrics from Python Sample App --- eric-oss-hello-world-python-app/main.py | 8 +------- eric-oss-hello-world-python-app/tests/conftest.py | 1 - eric-oss-hello-world-python-app/tests/test_main.py | 2 -- 3 files changed, 1 insertion(+), 10 deletions(-) diff --git a/eric-oss-hello-world-python-app/main.py b/eric-oss-hello-world-python-app/main.py index 8d3611b..acd3adb 100755 --- a/eric-oss-hello-world-python-app/main.py +++ b/eric-oss-hello-world-python-app/main.py @@ -25,7 +25,7 @@ class Application(Flask): def __init__(self): super().__init__(__name__) disable_created_metrics() - self.counters = {"total_failed": 0, "total_requests": 0} + self.counters = {"total_requests": 0} self.session = {"token": None, "expiry_time": 0} self.create_metrics() self.wsgi_app = DispatcherMiddleware( @@ -82,13 +82,7 @@ def create_metrics(self): name="requests_total", documentation="Total number of API requests", ) - self.requests_failed = Counter( - namespace=SERVICE_PREFIX, - name="requests_failed_total", - documentation="Total number of API request failures", - ) self.registry.register(self.requests_total) - self.registry.register(self.requests_failed) if __name__ == "__main__": diff --git a/eric-oss-hello-world-python-app/tests/conftest.py b/eric-oss-hello-world-python-app/tests/conftest.py index c5cda80..28eb8fb 100644 --- a/eric-oss-hello-world-python-app/tests/conftest.py +++ b/eric-oss-hello-world-python-app/tests/conftest.py @@ -80,7 +80,6 @@ def fixture_app(mock_log_api): # Why 'yield'? See: https://docs.pytest.org/en/7.1.x/how-to/fixtures.html#dynamic-scope yield application GLOBAL_METRICS_REGISTRY.unregister(application.requests_total) - GLOBAL_METRICS_REGISTRY.unregister(application.requests_failed) @pytest.fixture() diff --git a/eric-oss-hello-world-python-app/tests/test_main.py b/eric-oss-hello-world-python-app/tests/test_main.py index d99baab..177b883 100644 --- a/eric-oss-hello-world-python-app/tests/test_main.py +++ b/eric-oss-hello-world-python-app/tests/test_main.py @@ -29,7 +29,6 @@ def test_get_metrics_returns_metrics(client): response = client.get("/sample-app/python/metrics") assert response.status_code == 200 assert "python_hello_world_requests_total 0.0" in response.text - assert "python_hello_world_requests_failed_total 0.0" in response.text def test_metrics_does_not_expose_created(client): @@ -53,7 +52,6 @@ def test_metrics_successfully_increments(client): response = client.get("/sample-app/python/metrics") assert response.status_code == 200 assert "python_hello_world_requests_total 1.0" in response.text - assert "python_hello_world_requests_failed_total 0.0" in response.text def test_get_health_returns_health_check(client):