From 844bfe83d2138a7c5d7a4134862512cbe9e00135 Mon Sep 17 00:00:00 2001 From: Juan Negro Date: Tue, 12 Mar 2024 14:25:26 +0100 Subject: [PATCH] Restart callCount after each fetch --- .../src/main/java/com/example/demo/DataController.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/spring-app/src/main/java/com/example/demo/DataController.java b/spring-app/src/main/java/com/example/demo/DataController.java index cbf538a..6261bc3 100644 --- a/spring-app/src/main/java/com/example/demo/DataController.java +++ b/spring-app/src/main/java/com/example/demo/DataController.java @@ -15,9 +15,12 @@ class DataController { return ret; } - @GetMapping("/metrics") + @GetMapping(value = "/metrics", produces = "text/plain") String metrics() { - return "# HELP calls_count Total number of calls\n# TYPE calls_count counter\ncalls_count " + callsCount; + String returnMessage = "# HELP calls_count Total number of calls\n# TYPE calls_count counter\ncalls_count " + + callsCount + "\n"; + callsCount = 0; + return returnMessage; } }