Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions eric-oss-hello-world-python-app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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__":
Expand Down
1 change: 0 additions & 1 deletion eric-oss-hello-world-python-app/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 0 additions & 2 deletions eric-oss-hello-world-python-app/tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand Down