kumulant

CountStat

class CountStat(concurrency: Concurrency = Concurrency.None) : SeriesStat<SumResult> (source)

Observation count: each update contributes 1 regardless of supplied value and weight.

Use cases: event rate denominators, sample sizes, "how many".

Memory: O(1).

Update: O(1).

Concurrency: Inherits SumStat's concurrency model.

Constructors

CountStat

constructor(concurrency: Concurrency = Concurrency.None)(source)

Properties

Link copied to clipboard
open override val concurrency: Concurrency

Thread-safety mode fixed at construction. See Concurrency for the shared contract and the implementation's KDoc for its cell and lock strategy.

Functions

Link copied to clipboard
open override fun create(concurrency: Concurrency? = null): SeriesStat<SumResult>

Create an independent accumulator at the configured baseline. A null concurrency preserves this accumulator's mode; a non-null value overrides it. Modality subtypes narrow the return type to preserve the input shape.

Link copied to clipboard
open override fun merge(values: SumResult, timestampNanos: Long = currentTimeNanos())

Fold a compatible snapshot values into this accumulator at timestampNanos. Implementations document whether the combine is exact or approximate and which state the snapshot omits. The source accumulator is unaffected.

Link copied to clipboard
open override fun read(timestampNanos: Long = currentTimeNanos()): SumResult

Return the current result evaluated at timestampNanos. Time-independent statistics ignore the timestamp. Reading does not add an observation.

Link copied to clipboard
open override fun reset()

Restore the configured baseline, including any prior seed. Preserves the configuration and concurrency.

Link copied to clipboard
open override fun update(value: Double, weight: Double = 1.0)

Record value with weight at the current monotonic time.

open override fun update(value: Double, timestampNanos: Long, weight: Double = 1.0)

Record value with weight at timestampNanos.

Link copied to clipboard
open override fun validateMerge(values: SumResult)

Validate values for merge without changing accumulator state. Containers validate every child before merging any of them. Successful validation checks compatibility; it does not make a concurrent merge transactional.