Skip to content

Commit

Permalink
Handle different-length results more gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
leizor committed May 6, 2024
1 parent a0574d7 commit c8e84cc
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions cmd/foobar/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,19 @@ func checkHistogram(client remote.ReadClient, histogramBase string, hourStart ti
}
}

if len(res[0]) != len(res[1]) {
return -1, fmt.Errorf("result sets different lengths, %v != %v", len(res[0]), len(res[1]))
}

for ts, v0 := range res[0] {
v1 := res[1][ts]
if v0 != v1 {
return ts, nil
if len(res[0]) >= len(res[1]) {
for ts, v0 := range res[0] {
v1 := res[1][ts]
if v0 != v1 {
return ts, nil
}
}
} else {
for ts, v0 := range res[1] {
v1 := res[0][ts]
if v0 != v1 {
return ts, nil
}
}
}

Expand Down

0 comments on commit c8e84cc

Please sign in to comment.