Skip to content

Commit

Permalink
Fix logs, log min/maxt
Browse files Browse the repository at this point in the history
Signed-off-by: Oleg Zaytsev <[email protected]>
  • Loading branch information
colega committed Jan 3, 2025
1 parent 127fec0 commit dd72f6c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion tsdb/head_read.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ func (h *headIndexReader) SortedLabelValues(ctx context.Context, name string, ma
// If matchers are specified the returned result set is reduced
// to label values of metrics matching the matchers.
func (h *headIndexReader) LabelValues(ctx context.Context, name string, matchers ...*labels.Matcher) ([]string, error) {
if h.maxt < h.head.MinTime() || h.mint > h.head.MaxTime() {
headMinTime := h.head.MinTime()
headMaxTime := h.head.MaxTime()
if h.maxt < headMinTime || h.mint > headMaxTime {
fmt.Println("Returning empty label values for ", name, "because out of range:", "h.maxt=", h.maxt, "<", headMinTime, "=headMinTime || h.mint=", h.mint, " > ", headMaxTime, "=headMaxTime")
return []string{}, nil
}

Expand Down
6 changes: 5 additions & 1 deletion tsdb/querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,17 @@ func PostingsForMatchers(ctx context.Context, ix IndexPostingsReader, ms ...*lab
}
return fmt.Sprintf("%T", p)
}
if hr, ok := ix.(*headIndexReader); ok {
debug("h.maxt=%d, h.mint=%d", hr.maxt, hr.mint)
debug("h.head.MaxTime=%d, h.head.MinTime=%d", hr.head.MaxTime(), hr.head.MinTime())
}

var its, notIts []index.Postings
if troubleshoot {
defer func() {
selector := (&parser.VectorSelector{LabelMatchers: ms}).String()
traceID := trace.SpanFromContext(ctx).SpanContext().TraceID().String()
fmt.Printf("PostingsForMatchers(ix=%T, ms=%s, traceID=%s): %s", ix, selector, traceID, strings.Join(troubleshootData, ", "))
fmt.Printf("PostingsForMatchers(ix=%T, ms=%s, traceID=%s): %s\n", ix, selector, traceID, strings.Join(troubleshootData, ", "))
}()
}
// See which label must be non-empty.
Expand Down

0 comments on commit dd72f6c

Please sign in to comment.