MCPcopy Create free account
hub / github.com/cortexproject/cortex / Tick

Method Tick

pkg/util/math/rate.go:37–50  ·  view source on GitHub ↗

Tick assumes to be called every r.interval.

()

Source from the content-addressed store, hash-verified

35
36// Tick assumes to be called every r.interval.
37func (r *EwmaRate) Tick() {
38 newEvents := r.newEvents.Swap(0)
39 instantRate := float64(newEvents) / r.interval.Seconds()
40
41 r.mutex.Lock()
42 defer r.mutex.Unlock()
43
44 if r.init {
45 r.lastRate += r.alpha * (instantRate - r.lastRate)
46 } else {
47 r.init = true
48 r.lastRate = instantRate
49 }
50}
51
52// Inc counts one event.
53func (r *EwmaRate) Inc() {

Callers 9

runningMethod · 0.45
updateLoopMethod · 0.45
Test_Ingester_UserStatsFunction · 0.45
TestRateFunction · 0.45

Calls 1

SwapMethod · 0.45