Skip to content

Commit

Permalink
fix: sort circuitNames to have deterministic output of stats
Browse files Browse the repository at this point in the history
  • Loading branch information
gbotrel committed Sep 13, 2024
1 parent b12e158 commit 6ee601e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion internal/stats/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"io"
"os"
"sort"
"strconv"
"sync"

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6ee601e

Please sign in to comment.