Documentation
¶
Index ¶
- type MetricConstant
- type MetricConstantSpec
- type MetricGenerator
- type MetricGeneratorSpec
- type MetricNormalNoise
- type MetricNormalNoiseSpec
- type MetricPoissonNoise
- type MetricPoissonNoiseSpec
- type MetricRamp
- type MetricRampSpec
- type MetricRandomWalk
- type MetricRandomWalkSpec
- type MetricSpikyNoise
- type MetricSpikyNoiseSpec
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MetricConstant ¶
type MetricConstant struct {
// contains filtered or unexported fields
}
func NewMetricConstant ¶
func (*MetricConstant) Emit ¶
func (m *MetricConstant) Emit(_ *state.RunState, incoming float64) float64
func (*MetricConstant) Reconfigure ¶
type MetricConstantSpec ¶
type MetricConstantSpec struct { MetricGeneratorSpec `mapstructure:",squash"` Value float64 `mapstructure:"value" yaml:"value" json:"value"` }
type MetricGenerator ¶
type MetricGenerator interface { Emit(state *state.RunState, initial float64) float64 Reconfigure(at time.Duration, spec map[string]any) error }
func CreateMetricGenerator ¶
func CreateMetricGenerator(mes scriptaction.ScriptAction) (MetricGenerator, error)
type MetricGeneratorSpec ¶
type MetricGeneratorSpec struct {
Type string `mapstructure:"type" yaml:"type" json:"type"`
}
type MetricNormalNoise ¶ added in v0.4.0
type MetricNormalNoise struct {
// contains filtered or unexported fields
}
func NewMetricNormalNoise ¶ added in v0.4.0
func (*MetricNormalNoise) Emit ¶ added in v0.4.0
func (m *MetricNormalNoise) Emit(st *state.RunState, incoming float64) float64
func (*MetricNormalNoise) Reconfigure ¶ added in v0.4.0
type MetricNormalNoiseSpec ¶ added in v0.4.0
type MetricNormalNoiseSpec struct { MetricGeneratorSpec `mapstructure:",squash"` // Target is the mean around which Normal noise is drawn. Target float64 `mapstructure:"target" yaml:"target" json:"target"` // StdDev is the standard deviation of the normal distribution. StdDev float64 `mapstructure:"stdDev" yaml:"stdDev" json:"stdDev"` // Variation is the allowed max deviation from Target (for clamping). Variation float64 `mapstructure:"variation" yaml:"variation" json:"variation"` // Direction is the direction of the noise. Can be "positive", "negative", or // "both". "both" is the default. Direction string `mapstructure:"direction" yaml:"direction" json:"direction"` }
MetricNormalNoise emits independent normal noise centered on Target. On each Emit(), it samples:
x ~ Normal(Target, StdDev²)
then clamps x into [Target-Variation, Target+Variation]. Emit(in) returns in + x.
type MetricPoissonNoise ¶
type MetricPoissonNoise struct {
// contains filtered or unexported fields
}
func NewMetricPoissonNoise ¶
func (*MetricPoissonNoise) Emit ¶
func (m *MetricPoissonNoise) Emit(st *state.RunState, _ float64) float64
func (*MetricPoissonNoise) Reconfigure ¶
type MetricPoissonNoiseSpec ¶
type MetricPoissonNoiseSpec struct { MetricGeneratorSpec `mapstructure:",squash"` // Target is the expected events per Emit() interval. Target float64 `mapstructure:"target" yaml:"target" json:"target"` // Variation is the absolute max deviation from Target. Variation float64 `mapstructure:"variation" yaml:"variation" json:"variation"` // Direction: "positive" (default), "negative", or "both". Direction string `mapstructure:"direction" yaml:"direction" json:"direction"` }
MetricPoissonNoiseSpec drives a discrete-event noise generator. On each Emit(), it draws a Poisson count with mean = Target, then clamps it to [max(0,Target−Variation) … Target+Variation] and applies directionality.
type MetricRamp ¶
type MetricRamp struct {
// contains filtered or unexported fields
}
func NewMetricRamp ¶
func (*MetricRamp) Reconfigure ¶
type MetricRampSpec ¶
type MetricRampSpec struct { MetricGeneratorSpec `mapstructure:",squash"` Start float64 `mapstructure:"start" yaml:"start" json:"start"` Target float64 `mapstructure:"target" yaml:"target" json:"target"` Duration time.Duration `mapstructure:"duration" yaml:"duration" json:"duration"` PostEndZero bool `mapstructure:"postend_zero" yaml:"postend_zero" json:"postend_zero"` }
type MetricRandomWalk ¶
type MetricRandomWalk struct {
// contains filtered or unexported fields
}
func NewMetricRandomWalk ¶
func (*MetricRandomWalk) Emit ¶
func (m *MetricRandomWalk) Emit(state *state.RunState, incoming float64) float64
func (*MetricRandomWalk) Reconfigure ¶
type MetricRandomWalkSpec ¶
type MetricRandomWalkSpec struct { MetricGeneratorSpec `mapstructure:",squash"` Target float64 `mapstructure:"target" yaml:"target" json:"target"` Elasticity float64 `mapstructure:"elasticity" yaml:"elasticity" json:"elasticity"` StepSize float64 `mapstructure:"stepSize" yaml:"stepSize" json:"stepSize"` Variation float64 `mapstructure:"variation" yaml:"variation" json:"variation"` }
MetricRandomWalk emits an additive, mean-reverting noise term. On each Emit(), the internal state steps like:
x ← x + elasticity*(target - x) + Uniform(−stepSize,+stepSize)
then clamps into [target−variation, target+variation]. Emit(in) returns in + x.
type MetricSpikyNoise ¶
type MetricSpikyNoise struct {
// contains filtered or unexported fields
}
func NewMetricSpikyNoise ¶
func (*MetricSpikyNoise) Emit ¶
func (m *MetricSpikyNoise) Emit(st *state.RunState, incoming float64) float64
func (*MetricSpikyNoise) Reconfigure ¶
type MetricSpikyNoiseSpec ¶
type MetricSpikyNoiseSpec struct { MetricGeneratorSpec `mapstructure:",squash"` // PStart: chance per interval to transition from OFF→ON (0–1). PStart float64 `mapstructure:"pStart" yaml:"pStart" json:"pStart"` // PEnd: chance per interval to transition from ON→OFF (0–1). PEnd float64 `mapstructure:"pEnd" yaml:"pEnd" json:"pEnd"` // PeakTarget: mean count while in a spike. PeakTarget float64 `mapstructure:"peakTarget" yaml:"peakTarget" json:"peakTarget"` // Variation: max ± deviation around PeakTarget (clamped). Variation float64 `mapstructure:"variation" yaml:"variation" json:"variation"` // Direction: "positive" (default), "negative", or "both" Direction string `mapstructure:"direction" yaml:"direction" json:"direction"` }
MetricSpikyNoiseSpec configures a mostly‐zero generator that randomly spikes with Poisson‐distributed counts when “ON”.