Documentation ¶
Overview ¶
Package engine contains the internal metrics engine responsible for aggregating metrics during the test and evaluating thresholds against them.
Index ¶
Constants ¶
const IngesterDescription = "Internal Metrics Ingester"
IngesterDescription is a short description for ingester. This variable is used from a function in cmd/ui file for matching this output and print a special text.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MetricsEngine ¶
type MetricsEngine struct { // TODO: completely refactor: // - make these private, add a method to export the raw data // - do not use an unnecessary map for the observed metrics // - have one lock per metric instead of a a global one, when // the metrics are decoupled from their types MetricsLock sync.Mutex ObservedMetrics map[string]*metrics.Metric // contains filtered or unexported fields }
MetricsEngine is the internal metrics engine that k6 uses to keep track of aggregated metric sample values. They are used to generate the end-of-test summary and to evaluate the test thresholds.
func NewMetricsEngine ¶
func NewMetricsEngine(runState *lib.TestRunState) (*MetricsEngine, error)
NewMetricsEngine creates a new metrics Engine with the given parameters.
func (*MetricsEngine) CreateIngester ¶
func (me *MetricsEngine) CreateIngester() output.Output
CreateIngester returns a pseudo-Output that uses the given metric samples to update the engine's inner state.
func (*MetricsEngine) GetMetricsWithBreachedThresholdsCount ¶
func (me *MetricsEngine) GetMetricsWithBreachedThresholdsCount() uint32
GetMetricsWithBreachedThresholdsCount returns the number of metrics for which the thresholds were breached (failed) during the last processing phase. This API is safe to use concurrently.
func (*MetricsEngine) StartThresholdCalculations ¶
func (me *MetricsEngine) StartThresholdCalculations( abortRun func(error), getCurrentTestRunDuration func() time.Duration, ) (finalize func() (breached []string), )
StartThresholdCalculations spins up a new goroutine to crunch thresholds and returns a callback that will stop the goroutine and finalizes calculations.