metrics-0.2.1.0: High-performance application metric tracking

Safe HaskellNone

Data.Metrics.Reservoir

Description

A reservoir is the internal storage mechanism for a Histogram. It provides a generic way to store histogram values in a way that allows us to avoid the need to plumb the implementation type through anything that uses a reservoir.

Synopsis

Documentation

data Reservoir Source

Encapsulates the internal state of a reservoir implementation.

The two standard implementations are the ExponentiallyDecayingReservoir and the UniformReservoir.

Constructors

forall s . Reservoir 

Fields

_reservoirClear :: !(NominalDiffTime -> s -> s)

An operation that resets a reservoir to its initial state

_reservoirSize :: !(s -> Int)

Retrieve current size of the reservoir. This may or may not be constant depending on the specific implementation.

_reservoirSnapshot :: !(s -> Snapshot)

Take snapshot of the current reservoir.

The number of items in the snapshot should always match the reservoir's size.

_reservoirUpdate :: !(Double -> NominalDiffTime -> s -> s)

Add a new value to the reservoir, potentially evicting old values in the prcoess.

_reservoirState :: !s

The internal state of the reservoir.

clear :: NominalDiffTime -> Reservoir -> ReservoirSource

Reset a reservoir to its initial state.

size :: Reservoir -> IntSource

Get the current number of elements in the reservoir

snapshot :: Reservoir -> SnapshotSource

Get a copy of all elements in the reservoir.

update :: Double -> NominalDiffTime -> Reservoir -> ReservoirSource

Update a reservoir with a new value.

N.B. for some reservoir types, the latest value is not guaranteed to be retained in the reservoir.