Skip to content

Commit

Permalink
Fix to assert metrics query range before alignment because alignment …
Browse files Browse the repository at this point in the history
…may increase it, which is not the responsibility of the caller to account for (#4331)
  • Loading branch information
mdisibio authored Nov 15, 2024
1 parent 344743d commit 9cef442
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions modules/frontend/metrics_query_range_sharder.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,17 @@ func (s queryRangeSharder) RoundTrip(pipelineRequest pipeline.Request) (pipeline
return pipeline.NewBadRequest(errors.New("step must be greater than 0")), nil
}

traceql.AlignRequest(req)

// calculate and enforce max search duration
// Note: this is checked after alignment for consistency.
// This is checked before alignment because we may need to read a larger
// range internally to satisfy the query.
maxDuration := s.maxDuration(tenantID)
if maxDuration != 0 && time.Duration(req.End-req.Start)*time.Nanosecond > maxDuration {
err = fmt.Errorf("range specified by start and end (%s) exceeds %s. received start=%d end=%d", time.Duration(req.End-req.Start), maxDuration, req.Start, req.End)
return pipeline.NewBadRequest(err), nil
}

traceql.AlignRequest(req)

var maxExemplars uint32
// Instant queries must not compute exemplars
if !s.instantMode && s.cfg.MaxExemplars > 0 {
Expand Down

0 comments on commit 9cef442

Please sign in to comment.