Discover Packages
mosn.io/mosn
pkg
metrics
ewma
package
Version:
v1.5.0
Opens a new window with list of versions in this module.
Published: Apr 25, 2023
License: Apache-2.0
Opens a new window with license information.
Imports: 4
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
Documentation
Documentation
¶
Alpha the alpha needed to decay 1 to negligible (less than target) over a given duration.
(1 - alpha) ^ duration = target ==> alpha = 1 - target ^ (1 / duration).
NewEWMA constructs a new EWMA with the given alpha.
EWMA is the standard EWMA implementation, it updates in real time
and when queried it always returns the decayed value.
See: https://en.wikipedia.org/wiki/Moving_average#Exponential_moving_average
Rate returns the moving average mean of events per second.
Snapshot returns a read-only copy of the EWMA.
Tick ticks the clock to update the moving average.
There is no need to use an additional timer to Tick in this implementation,
because Rate also calculates the latest value when it is updated or queried.
Update adds an uncounted event with value `i`, and tries to flush.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.