From 5cacf23b85eb772697acbe459e4335cea08339ff Mon Sep 17 00:00:00 2001 From: Paramadon Date: Wed, 11 Dec 2024 14:39:22 -0500 Subject: [PATCH] shouldn't add to stats map if ShouldResetStats is false --- .../agenthealth/handler/stats/provider/statuscode.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/extension/agenthealth/handler/stats/provider/statuscode.go b/extension/agenthealth/handler/stats/provider/statuscode.go index b17d571112..bfa6052fc1 100644 --- a/extension/agenthealth/handler/stats/provider/statuscode.go +++ b/extension/agenthealth/handler/stats/provider/statuscode.go @@ -5,6 +5,7 @@ package provider import ( "context" + "log" "net/http" "sync" "time" @@ -97,6 +98,7 @@ func (sp *StatusCodeProvider) processStatusCode(entry statusCodeEntry) { } func (sp *StatusCodeProvider) updateStatusCodeCount(stats *[5]int, statusCode int) { + log.Printf("Updating status code count: statusCode=%d\n", statusCode) switch statusCode { case 200: stats[0]++ @@ -108,7 +110,13 @@ func (sp *StatusCodeProvider) updateStatusCodeCount(stats *[5]int, statusCode in stats[3]++ case 429: stats[4]++ + default: + log.Printf("Unknown status code encountered: %d\n", statusCode) } + log.Printf( + "Updated stats for operation --: 200=%d, 400=%d, 408=%d, 413=%d, 429=%d", + stats[0], stats[1], stats[2], stats[3], stats[4], + ) } func (sp *StatusCodeProvider) startResetTimer() { @@ -130,10 +138,6 @@ func (sp *StatusCodeProvider) Stats(_ string) agent.Stats { } sp.StatsByOperation = make(map[string]*[5]int) sp.ShouldResetStats = false - } else { - for op, stats := range sp.StatsByOperation { - statusCodeMap[op] = *stats - } } return agent.Stats{