Documentation ¶
Index ¶
- func NewSample(reservoirSize int, window time.Duration) metrics.Sample
- type Sample
- func (s *Sample) Clear()
- func (s *Sample) Count() int64
- func (s *Sample) Max() int64
- func (s *Sample) Mean() float64
- func (s *Sample) Min() int64
- func (s *Sample) Percentile(p float64) float64
- func (s *Sample) Percentiles(ps []float64) []float64
- func (s *Sample) Size() int
- func (s *Sample) Snapshot() metrics.Sample
- func (s *Sample) StdDev() float64
- func (s *Sample) Sum() int64
- func (s *Sample) Update(v int64)
- func (s *Sample) Values() []int64
- func (s *Sample) Variance() float64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewSample ¶
NewSample constructs a new sliding-window sample over the given time window. At the end of each window the metrics outside the window are removed. This is an ideal sampling method for low-volume metrics where sample values would stick around indefinitely because there was not a steady stream of new metrics. Please note that the reservoir size is the size of two in-memory slices of int64s and time. Times used to hold the sample values and times. Therefore, if a large reservoir size is used it can be an extremely inefficient use of memory.
Types ¶
type Sample ¶
type Sample struct {
// contains filtered or unexported fields
}
Sample is a sliding window sample with a maximum reservoir size in the window.
func (*Sample) Percentile ¶
Percentile returns an arbitrary percentile of values in the sample.
func (*Sample) Percentiles ¶
Percentiles returns a slice of arbitrary percentiles of values in the sample.
func (*Sample) Size ¶
Size returns the size of the sample, which will not exceed the reservoir size.
func (*Sample) Snapshot ¶
func (s *Sample) Snapshot() metrics.Sample
Snapshot returns a copy of the samples that is flushed to graphite.