mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/streamaggr: added rate_sum and rate_avg to benchmarks, lint fix (#6264)
fixed lint for rate outputs
This commit is contained in:
parent
9c3d44c8c9
commit
ce25d68b45
2 changed files with 6 additions and 4 deletions
|
@ -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" {
|
||||
|
|
|
@ -15,6 +15,8 @@ var benchOutputs = []string{
|
|||
"total_prometheus",
|
||||
"increase",
|
||||
"increase_prometheus",
|
||||
"rate_sum",
|
||||
"rate_avg",
|
||||
"count_series",
|
||||
"count_samples",
|
||||
"unique_samples",
|
||||
|
|
Loading…
Reference in a new issue