Skip to content

Commit

Permalink
Log information about failing series when range vector result compari…
Browse files Browse the repository at this point in the history
…son fails
  • Loading branch information
charleskorn committed Jul 15, 2024
1 parent 4aa99a4 commit 0147308
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions tools/querytee/response_comparator.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package querytee
import (
"encoding/json"
"fmt"
"github.com/go-kit/log"
"math"
"slices"
"time"
Expand Down Expand Up @@ -147,11 +148,33 @@ func compareMatrix(expectedRaw, actualRaw json.RawMessage, opts SampleComparison
actualHistogramSamplesCount,
)

shouldLog := false
logger := util_log.Logger

if expectedFloatSamplesCount > 0 && actualFloatSamplesCount > 0 {
level.Error(util_log.Logger).Log("msg", err.Error(), "oldest-expected-ts", expectedMetric.Values[0].Timestamp,
"newest-expected-ts", expectedMetric.Values[expectedFloatSamplesCount-1].Timestamp,
"oldest-actual-ts", actualMetric.Values[0].Timestamp, "newest-actual-ts", actualMetric.Values[actualFloatSamplesCount-1].Timestamp)
logger = log.With(logger,
"oldest-expected-float-ts", expectedMetric.Values[0].Timestamp,
"newest-expected-float-ts", expectedMetric.Values[expectedFloatSamplesCount-1].Timestamp,
"oldest-actual-float-ts", actualMetric.Values[0].Timestamp,
"newest-actual-float-ts", actualMetric.Values[actualFloatSamplesCount-1].Timestamp,
)
shouldLog = true
}

if expectedHistogramSamplesCount > 0 && actualHistogramSamplesCount > 0 {
logger = log.With(logger,
"oldest-expected-histogram-ts", expectedMetric.Histograms[0].Timestamp,
"newest-expected-histogram-ts", expectedMetric.Histograms[expectedHistogramSamplesCount-1].Timestamp,
"oldest-actual-histogram-ts", actualMetric.Histograms[0].Timestamp,
"newest-actual-histogram-ts", actualMetric.Histograms[actualHistogramSamplesCount-1].Timestamp,
)
shouldLog = true
}

if shouldLog {
level.Error(logger).Log("msg", err.Error())
}

return err
}

Expand Down

0 comments on commit 0147308

Please sign in to comment.