lib/streamaggr: added rate_sum and rate_avg to benchmarks, lint fix (#6264)

fixed lint for rate outputs
This commit is contained in:
Andrii Chubatiuk 2024-05-13 17:40:37 +03:00 committed by GitHub
parent 9c3d44c8c9
commit ce25d68b45
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 4 deletions

View File

@ -19,7 +19,7 @@ type rateAggrState struct {
type rateStateValue struct {
mu sync.Mutex
lastValues map[string]*rateLastValueState
lastValues map[string]rateLastValueState
deleteDeadline uint64
deleted bool
}
@ -57,7 +57,7 @@ func (as *rateAggrState) pushSamples(samples []pushSample) {
if !ok {
// The entry is missing in the map. Try creating it.
v = &rateStateValue{
lastValues: make(map[string]*rateLastValueState),
lastValues: make(map[string]rateLastValueState),
}
vNew, loaded := as.m.LoadOrStore(outputKey, v)
if loaded {
@ -85,8 +85,6 @@ func (as *rateAggrState) pushSamples(samples []pushSample) {
// counter reset
lv.total += s.value
}
} else {
lv = &rateLastValueState{}
}
lv.value = s.value
lv.timestamp = s.timestamp
@ -104,6 +102,7 @@ func (as *rateAggrState) pushSamples(samples []pushSample) {
}
func (as *rateAggrState) flushState(ctx *flushCtx, resetState bool) {
_ = resetState // it isn't used here
currentTime := fasttime.UnixTimestamp()
currentTimeMsec := int64(currentTime) * 1000
@ -132,6 +131,7 @@ func (as *rateAggrState) flushState(ctx *flushCtx, resetState bool) {
rate += v1.total * 1000 / float64(v1.timestamp-v1.prevTimestamp)
v1.prevTimestamp = v1.timestamp
v1.total = 0
m[k1] = v1
}
}
if as.suffix == "rate_avg" {

View File

@ -15,6 +15,8 @@ var benchOutputs = []string{
"total_prometheus",
"increase",
"increase_prometheus",
"rate_sum",
"rate_avg",
"count_series",
"count_samples",
"unique_samples",