mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-03-21 15:45:01 +00:00
lib/streamaggr: added rate_sum and rate_avg to benchmarks, lint fix (#6264)
fixed lint for rate outputs
(cherry picked from commit ce25d68b45
)
This commit is contained in:
parent
d9cddf1ad8
commit
b9eb527d98
2 changed files with 6 additions and 4 deletions
|
@ -19,7 +19,7 @@ type rateAggrState struct {
|
||||||
|
|
||||||
type rateStateValue struct {
|
type rateStateValue struct {
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
lastValues map[string]*rateLastValueState
|
lastValues map[string]rateLastValueState
|
||||||
deleteDeadline uint64
|
deleteDeadline uint64
|
||||||
deleted bool
|
deleted bool
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ func (as *rateAggrState) pushSamples(samples []pushSample) {
|
||||||
if !ok {
|
if !ok {
|
||||||
// The entry is missing in the map. Try creating it.
|
// The entry is missing in the map. Try creating it.
|
||||||
v = &rateStateValue{
|
v = &rateStateValue{
|
||||||
lastValues: make(map[string]*rateLastValueState),
|
lastValues: make(map[string]rateLastValueState),
|
||||||
}
|
}
|
||||||
vNew, loaded := as.m.LoadOrStore(outputKey, v)
|
vNew, loaded := as.m.LoadOrStore(outputKey, v)
|
||||||
if loaded {
|
if loaded {
|
||||||
|
@ -85,8 +85,6 @@ func (as *rateAggrState) pushSamples(samples []pushSample) {
|
||||||
// counter reset
|
// counter reset
|
||||||
lv.total += s.value
|
lv.total += s.value
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
lv = &rateLastValueState{}
|
|
||||||
}
|
}
|
||||||
lv.value = s.value
|
lv.value = s.value
|
||||||
lv.timestamp = s.timestamp
|
lv.timestamp = s.timestamp
|
||||||
|
@ -104,6 +102,7 @@ func (as *rateAggrState) pushSamples(samples []pushSample) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (as *rateAggrState) flushState(ctx *flushCtx, resetState bool) {
|
func (as *rateAggrState) flushState(ctx *flushCtx, resetState bool) {
|
||||||
|
_ = resetState // it isn't used here
|
||||||
currentTime := fasttime.UnixTimestamp()
|
currentTime := fasttime.UnixTimestamp()
|
||||||
currentTimeMsec := int64(currentTime) * 1000
|
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)
|
rate += v1.total * 1000 / float64(v1.timestamp-v1.prevTimestamp)
|
||||||
v1.prevTimestamp = v1.timestamp
|
v1.prevTimestamp = v1.timestamp
|
||||||
v1.total = 0
|
v1.total = 0
|
||||||
|
m[k1] = v1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if as.suffix == "rate_avg" {
|
if as.suffix == "rate_avg" {
|
||||||
|
|
|
@ -15,6 +15,8 @@ var benchOutputs = []string{
|
||||||
"total_prometheus",
|
"total_prometheus",
|
||||||
"increase",
|
"increase",
|
||||||
"increase_prometheus",
|
"increase_prometheus",
|
||||||
|
"rate_sum",
|
||||||
|
"rate_avg",
|
||||||
"count_series",
|
"count_series",
|
||||||
"count_samples",
|
"count_samples",
|
||||||
"unique_samples",
|
"unique_samples",
|
||||||
|
|
Loading…
Reference in a new issue