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 f92255e803
commit 4ce1368e4b

View file

@ -130,6 +130,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
@ -149,6 +152,7 @@ func (s *Search) reset() {
s.storage = nil
s.ts.reset()
s.tr = TimeRange{}
s.tfss = nil
s.deadline = 0
s.err = nil
@ -167,6 +171,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
@ -203,7 +208,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.