From 6ee601e258c8f5bcc1e32b6c3155d023d88b7e42 Mon Sep 17 00:00:00 2001 From: Gautam Botrel Date: Fri, 13 Sep 2024 10:19:55 -0500 Subject: [PATCH] fix: sort circuitNames to have deterministic output of stats --- internal/stats/stats.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/internal/stats/stats.go b/internal/stats/stats.go index 160f37152..75db39af0 100644 --- a/internal/stats/stats.go +++ b/internal/stats/stats.go @@ -5,6 +5,7 @@ import ( "fmt" "io" "os" + "sort" "strconv" "sync" @@ -38,8 +39,17 @@ func (s *globalStats) WriteTo(w io.Writer) (int64, error) { return 0, err } + // sort circuits names to have a deterministic output + var circuitNames []string + for circuitName := range s.Stats { + circuitNames = append(circuitNames, circuitName) + } + + sort.Strings(circuitNames) + // write data - for circuitName, innerStats := range s.Stats { + for _, circuitName := range circuitNames { + innerStats := s.Stats[circuitName] for backendID, s := range innerStats { if backendID == 0 { continue