Skip to content

Commit

Permalink
Print positive matches too for 1 metric
Browse files Browse the repository at this point in the history
Signed-off-by: Marco Pracucci <[email protected]>
  • Loading branch information
pracucci committed Jan 3, 2025
1 parent 69ffc1e commit 3df8288
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions tsdb/querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,11 @@ func (s MatchersStringer) String() string {
return b.String()
}


// PostingsForMatchers assembles a single postings iterator against the index reader
// based on the given matchers. The resulting postings are not ordered by series.
func PostingsForMatchers(ctx context.Context, ix IndexPostingsReader, ms ...*labels.Matcher) (index.Postings, error) {
// Ensure the matchers are the expected ones.
if expectedMatchersAny := ctx.Value(OriginalMatchersCtxKey); expectedMatchersAny != nil {
if expectedMatchersAny := ctx.Value(OriginalMatchersCtxKey); expectedMatchersAny != nil {
expectedMatchers := expectedMatchersAny.([]*labels.Matcher)

// Make a copy of the actual matchers and then sort them for a stable comparison.
Expand All @@ -223,6 +222,14 @@ func PostingsForMatchers(ctx context.Context, ix IndexPostingsReader, ms ...*lab
// Ensure they're the same.
if !SameMatchers(expectedMatchers, actualMatchers) {
fmt.Println("PostingsForMatchers() received matchers different than the expected ones, expected:", MatchersStringer(expectedMatchers).String(), "actual:", MatchersStringer(actualMatchers).String())
} else {
// Check whether it's matching the metric we mostly use for debugging.
for _, m := range expectedMatchers {
if m.Type == labels.MatchEqual && m.Name == labels.MetricName && m.Value == "tempo_request_duration_seconds_bucket" {
fmt.Println("PostingsForMatchers() received matchers equal to the expected ones, matchers:", MatchersStringer(expectedMatchers).String())
break
}
}
}
}

Expand Down

0 comments on commit 3df8288

Please sign in to comment.