lib/storage: mention time range used in the query that led to error message

This should improve detecting slow queries with too big time ranges
This commit is contained in:
Aliaksandr Valialkin 2020-08-10 13:45:44 +03:00
parent 582c74cd93
commit 8d9eb5f808

View file

@ -65,6 +65,9 @@ type Search struct {
ts tableSearch
// tr contains time range used in the serach.
tr TimeRange
// tfss contains tag filters used in the search.
tfss []*TagFilters
@ -84,6 +87,7 @@ func (s *Search) reset() {
s.storage = nil
s.ts.reset()
s.tr = TimeRange{}
s.tfss = nil
s.deadline = 0
s.err = nil
@ -102,6 +106,7 @@ func (s *Search) Init(storage *Storage, tfss []*TagFilters, tr TimeRange, maxMet
}
s.reset()
s.tr = tr
s.tfss = tfss
s.deadline = deadline
s.needClosing = true
@ -138,7 +143,7 @@ func (s *Search) Error() error {
if s.err == io.EOF || s.err == nil {
return nil
}
return fmt.Errorf("error when searching for tagFilters=%s: %w", s.tfss, s.err)
return fmt.Errorf("error when searching for tagFilters=%s on the time range %s: %w", s.tfss, s.tr.String(), s.err)
}
// NextMetricBlock proceeds to the next MetricBlockRef.