Help us shape the future of Go! Take the 2026 Go Developer Survey

compute

package
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 2, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func KahanSumInc

func KahanSumInc(inc, sum, c float64) (newSum, newC float64)

KahanSumInc implements kahan summation, see https://en.wikipedia.org/wiki/Kahan_summation_algorithm.

func Quantile

func Quantile(q float64, points []float64) float64

Types

type Accumulator

type Accumulator interface {
	Add(v float64, h *histogram.FloatHistogram) error
	Value() (float64, *histogram.FloatHistogram)
	ValueType() ValueType
	Warnings() warnings.Warnings
	Reset(float64)
}

Accumulators map prometheus behavior for aggregations, either operators or "[...]_over_time" functions. The caller is responsible to add all errors returned by Add as annotations. The Warnings method returns a bitset of warning conditions that occurred during accumulation (e.g., ignored histograms, mixed types).

func NewQuantileAcc

func NewQuantileAcc() Accumulator

type AvgAcc

type AvgAcc struct {
	// contains filtered or unexported fields
}

func NewAvgAcc

func NewAvgAcc() *AvgAcc

func (*AvgAcc) Add

func (*AvgAcc) AddVector

func (a *AvgAcc) AddVector(vs []float64, hs []*histogram.FloatHistogram) error

func (*AvgAcc) Reset

func (a *AvgAcc) Reset(_ float64)

func (*AvgAcc) Value

func (a *AvgAcc) Value() (float64, *histogram.FloatHistogram)

func (*AvgAcc) ValueType

func (a *AvgAcc) ValueType() ValueType

func (*AvgAcc) Warnings added in v0.5.0

func (a *AvgAcc) Warnings() warnings.Warnings

type CountAcc

type CountAcc struct {
	// contains filtered or unexported fields
}

func NewCountAcc

func NewCountAcc() *CountAcc

func (*CountAcc) Add

func (*CountAcc) AddVector

func (c *CountAcc) AddVector(vs []float64, hs []*histogram.FloatHistogram) error

func (*CountAcc) Reset

func (c *CountAcc) Reset(_ float64)

func (*CountAcc) Value

func (c *CountAcc) Value() (float64, *histogram.FloatHistogram)

func (*CountAcc) ValueType

func (c *CountAcc) ValueType() ValueType

func (*CountAcc) Warnings added in v0.5.0

func (c *CountAcc) Warnings() warnings.Warnings

type CounterResetState added in v0.5.0

type CounterResetState uint8

CounterResetState tracks which counter reset hints have been seen during aggregation. Used to detect collisions between CounterReset and NotCounterReset hints.

const (
	SeenCounterReset    CounterResetState = 1 << iota // histogram with CounterReset hint was seen
	SeenNotCounterReset                               // histogram with NotCounterReset hint was seen
)

func (CounterResetState) HasCollision added in v0.5.0

func (s CounterResetState) HasCollision() bool

HasCollision returns true if both CounterReset and NotCounterReset hints were seen.

type GroupAcc

type GroupAcc struct {
	// contains filtered or unexported fields
}

func NewGroupAcc

func NewGroupAcc() *GroupAcc

func (*GroupAcc) Add

func (*GroupAcc) AddVector

func (c *GroupAcc) AddVector(vs []float64, hs []*histogram.FloatHistogram) error

func (*GroupAcc) Reset

func (c *GroupAcc) Reset(_ float64)

func (*GroupAcc) Value

func (c *GroupAcc) Value() (float64, *histogram.FloatHistogram)

func (*GroupAcc) ValueType

func (c *GroupAcc) ValueType() ValueType

func (*GroupAcc) Warnings added in v0.5.0

func (c *GroupAcc) Warnings() warnings.Warnings

type HistogramAvgAcc

type HistogramAvgAcc struct {
	// contains filtered or unexported fields
}

func NewHistogramAvgAcc

func NewHistogramAvgAcc() *HistogramAvgAcc

func (*HistogramAvgAcc) Add

func (*HistogramAvgAcc) Reset

func (acc *HistogramAvgAcc) Reset(f float64)

func (*HistogramAvgAcc) Value

func (*HistogramAvgAcc) ValueType

func (acc *HistogramAvgAcc) ValueType() ValueType

func (*HistogramAvgAcc) Warnings added in v0.5.0

func (acc *HistogramAvgAcc) Warnings() warnings.Warnings

type LastAcc added in v0.5.0

type LastAcc struct {
	// contains filtered or unexported fields
}

LastAcc tracks the last value seen. Used for last_over_time.

func NewLastAcc added in v0.5.0

func NewLastAcc() *LastAcc

func (*LastAcc) Add added in v0.5.0

func (*LastAcc) Reset added in v0.5.0

func (l *LastAcc) Reset(_ float64)

func (*LastAcc) Value added in v0.5.0

func (l *LastAcc) Value() (float64, *histogram.FloatHistogram)

func (*LastAcc) ValueType added in v0.5.0

func (l *LastAcc) ValueType() ValueType

func (*LastAcc) Warnings added in v0.5.0

func (l *LastAcc) Warnings() warnings.Warnings

type MaxAcc

type MaxAcc struct {
	// contains filtered or unexported fields
}

func NewMaxAcc

func NewMaxAcc() *MaxAcc

func (*MaxAcc) Add

func (*MaxAcc) AddVector

func (c *MaxAcc) AddVector(vs []float64, hs []*histogram.FloatHistogram) error

func (*MaxAcc) Reset

func (c *MaxAcc) Reset(_ float64)

func (*MaxAcc) Value

func (c *MaxAcc) Value() (float64, *histogram.FloatHistogram)

func (*MaxAcc) ValueType

func (c *MaxAcc) ValueType() ValueType

func (*MaxAcc) Warnings added in v0.5.0

func (c *MaxAcc) Warnings() warnings.Warnings

type MinAcc

type MinAcc struct {
	// contains filtered or unexported fields
}

func NewMinAcc

func NewMinAcc() *MinAcc

func (*MinAcc) Add

func (*MinAcc) AddVector

func (c *MinAcc) AddVector(vs []float64, hs []*histogram.FloatHistogram) error

func (*MinAcc) Reset

func (c *MinAcc) Reset(_ float64)

func (*MinAcc) Value

func (c *MinAcc) Value() (float64, *histogram.FloatHistogram)

func (*MinAcc) ValueType

func (c *MinAcc) ValueType() ValueType

func (*MinAcc) Warnings added in v0.5.0

func (c *MinAcc) Warnings() warnings.Warnings

type QuantileAcc

type QuantileAcc struct {
	// contains filtered or unexported fields
}

func (*QuantileAcc) Add

func (*QuantileAcc) Reset

func (q *QuantileAcc) Reset(f float64)

func (*QuantileAcc) Value

func (*QuantileAcc) ValueType

func (q *QuantileAcc) ValueType() ValueType

func (*QuantileAcc) Warnings added in v0.5.0

func (q *QuantileAcc) Warnings() warnings.Warnings

type StdDevAcc

type StdDevAcc struct {
	// contains filtered or unexported fields
}

func NewStdDevAcc

func NewStdDevAcc() *StdDevAcc

func (*StdDevAcc) Add

func (*StdDevAcc) Reset

func (s *StdDevAcc) Reset(_ float64)

func (*StdDevAcc) Value

func (s *StdDevAcc) Value() (float64, *histogram.FloatHistogram)

func (*StdDevAcc) ValueType

func (s *StdDevAcc) ValueType() ValueType

func (*StdDevAcc) Warnings added in v0.5.0

func (s *StdDevAcc) Warnings() warnings.Warnings

type StdVarAcc

type StdVarAcc struct {
	// contains filtered or unexported fields
}

func NewStdVarAcc

func NewStdVarAcc() *StdVarAcc

func (*StdVarAcc) Add

func (*StdVarAcc) Reset

func (s *StdVarAcc) Reset(_ float64)

func (*StdVarAcc) Value

func (s *StdVarAcc) Value() (float64, *histogram.FloatHistogram)

func (*StdVarAcc) ValueType

func (s *StdVarAcc) ValueType() ValueType

func (*StdVarAcc) Warnings added in v0.5.0

func (s *StdVarAcc) Warnings() warnings.Warnings

type SumAcc

type SumAcc struct {
	// contains filtered or unexported fields
}

func NewSumAcc

func NewSumAcc() *SumAcc

func (*SumAcc) Add

func (*SumAcc) AddVector

func (s *SumAcc) AddVector(float64s []float64, histograms []*histogram.FloatHistogram) error

func (*SumAcc) Reset

func (s *SumAcc) Reset(_ float64)

func (*SumAcc) Value

func (s *SumAcc) Value() (float64, *histogram.FloatHistogram)

func (*SumAcc) ValueType

func (s *SumAcc) ValueType() ValueType

func (*SumAcc) Warnings added in v0.5.0

func (s *SumAcc) Warnings() warnings.Warnings

type ValueType

type ValueType int
const (
	NoValue ValueType = iota
	SingleTypeValue
	MixedTypeValue
)

type VectorAccumulator

type VectorAccumulator interface {
	AddVector(vs []float64, hs []*histogram.FloatHistogram) error
	Value() (float64, *histogram.FloatHistogram)
	ValueType() ValueType
	Warnings() warnings.Warnings
	Reset(float64)
}

VectorAccumulator is like Accumulator but accepts batches of values.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL