mirror of https://github.com/grafana/loki
Fix instant query summary split stats (#9773)
**What this PR does / why we need it**:
Fix instant query summary statistic's `splits` corresponding to the
number of subqueries a query is split into based on
`split_queries_by_interval`.
* Update rangemapper with a statistics structure to include the number
of split queries a query is mapped into.
* In the `split_by_range` middleware once the mapped query is returned
update the middleware statistics with the number of split queries. This
value will then be merged with the statistics of the Loki response.
**Checklist**
- [ ] Reviewed the
[`CONTRIBUTING.md`](https://github.com/grafana/loki/blob/main/CONTRIBUTING.md)
guide (**required**)
- [ ] Documentation added
- [x] Tests updated
- [x] `CHANGELOG.md` updated
- [ ] If the change is worth mentioning in the release notes, add
`add-to-release-notes` label
- [ ] Changes that require user attention or interaction to upgrade are
documented in `docs/sources/upgrading/_index.md`
- [ ] For Helm chart changes bump the Helm chart version in
`production/helm/loki/Chart.yaml` and update
`production/helm/loki/CHANGELOG.md` and
`production/helm/loki/README.md`. [Example
PR](d10549e3ec)
pull/9780/head
parent
86d943d8f4
commit
35465d0297
@ -0,0 +1,24 @@ |
||||
package logql |
||||
|
||||
type MapperStats struct { |
||||
splitQueries int |
||||
} |
||||
|
||||
func NewMapperStats() *MapperStats { |
||||
return &MapperStats{} |
||||
} |
||||
|
||||
// AddSplitQueries add num split queries to the counter
|
||||
func (s *MapperStats) AddSplitQueries(num int) { |
||||
s.splitQueries += num |
||||
} |
||||
|
||||
// GetSplitQueries returns the number of split queries
|
||||
func (s *MapperStats) GetSplitQueries() int { |
||||
return s.splitQueries |
||||
} |
||||
|
||||
// resetSplitQueries resets the number of split queries
|
||||
func (s *MapperStats) resetSplitQueries() { |
||||
s.splitQueries = 0 |
||||
} |
||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue