Merge pull request #16697 from Konstantinov-Innokentii/export-query-samples-fields
Some checks are pending
buf.build / lint and publish (push) Waiting to run
CI / Go tests (push) Waiting to run
CI / More Go tests (push) Waiting to run
CI / Go tests with previous Go version (push) Waiting to run
CI / UI tests (push) Waiting to run
CI / Go tests on Windows (push) Waiting to run
CI / Mixins tests (push) Waiting to run
CI / Build Prometheus for common architectures (push) Waiting to run
CI / Build Prometheus for all architectures (push) Waiting to run
CI / Report status of build Prometheus for all architectures (push) Blocked by required conditions
CI / Check generated parser (push) Waiting to run
CI / golangci-lint (push) Waiting to run
CI / fuzzing (push) Waiting to run
CI / codeql (push) Waiting to run
CI / Publish main branch artifacts (push) Blocked by required conditions
CI / Publish release artefacts (push) Blocked by required conditions
CI / Publish UI on npm Registry (push) Blocked by required conditions
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run

stats: Export QuerySamples StartTimestamp and Interval fields
This commit is contained in:
Björn Rabenstein 2025-06-10 15:05:22 +02:00 committed by GitHub
commit ea75bc18e9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -182,7 +182,7 @@ func (qs *QuerySamples) totalSamplesPerStepPoints() []stepStat {
ts := make([]stepStat, len(qs.TotalSamplesPerStep))
for i, c := range qs.TotalSamplesPerStep {
ts[i] = stepStat{T: qs.startTimestamp + int64(i)*qs.interval, V: c}
ts[i] = stepStat{T: qs.StartTimestamp + int64(i)*qs.Interval, V: c}
}
return ts
}
@ -246,8 +246,8 @@ type QuerySamples struct {
TotalSamplesPerStep []int64
EnablePerStepStats bool
startTimestamp int64
interval int64
StartTimestamp int64
Interval int64
}
type Stats struct {
@ -262,8 +262,8 @@ func (qs *QuerySamples) InitStepTracking(start, end, interval int64) {
numSteps := int((end-start)/interval) + 1
qs.TotalSamplesPerStep = make([]int64, numSteps)
qs.startTimestamp = start
qs.interval = interval
qs.StartTimestamp = start
qs.Interval = interval
}
// IncrementSamplesAtStep increments the total samples count. Use this if you know the step index.
@ -287,7 +287,7 @@ func (qs *QuerySamples) IncrementSamplesAtTimestamp(t, samples int64) {
qs.TotalSamples += samples
if qs.TotalSamplesPerStep != nil {
i := int((t - qs.startTimestamp) / qs.interval)
i := int((t - qs.StartTimestamp) / qs.Interval)
qs.TotalSamplesPerStep[i] += samples
}
}