Documentation ¶
Overview ¶
Package engine contains the internal metrics engine responsible for aggregating metrics during the test and evaluating thresholds against them.
Index ¶
- Constants
- type MetricsEngine
- func (me *MetricsEngine) CreateIngester() *OutputIngester
- func (me *MetricsEngine) GetMetricsWithBreachedThresholdsCount() uint32
- func (me *MetricsEngine) InitSubMetricsAndThresholds(options lib.Options, onlyLogErrors bool) error
- func (me *MetricsEngine) StartThresholdCalculations(ingester *OutputIngester, abortRun func(error), ...) (finalize func() (breached []string))
- type OutputIngester
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(registry *metrics.Registry, logger logrus.FieldLogger) (*MetricsEngine, error)
NewMetricsEngine creates a new metrics Engine with the given parameters.
func (*MetricsEngine) CreateIngester ¶ added in v0.43.0
func (me *MetricsEngine) CreateIngester() *OutputIngester
CreateIngester returns a pseudo-Output that uses the given metric samples to update the engine's inner state.
func (*MetricsEngine) GetMetricsWithBreachedThresholdsCount ¶ added in v0.43.0
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) InitSubMetricsAndThresholds ¶ added in v0.46.0
func (me *MetricsEngine) InitSubMetricsAndThresholds(options lib.Options, onlyLogErrors bool) error
InitSubMetricsAndThresholds parses the thresholds from the test Options and initializes both the thresholds themselves, as well as any submetrics that were referenced in them.
func (*MetricsEngine) StartThresholdCalculations ¶ added in v0.43.0
func (me *MetricsEngine) StartThresholdCalculations( ingester *OutputIngester, 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.
type OutputIngester ¶ added in v0.46.0
type OutputIngester struct { output.SampleBuffer // contains filtered or unexported fields }
OutputIngester implements the output.Output interface and can be used to "feed" the MetricsEngine data from a `k6 run` test run.
func (*OutputIngester) Description ¶ added in v0.46.0
func (oi *OutputIngester) Description() string
Description returns a human-readable description of the output.
func (*OutputIngester) Start ¶ added in v0.46.0
func (oi *OutputIngester) Start() error
Start the engine by initializing a new output.PeriodicFlusher
func (*OutputIngester) Stop ¶ added in v0.46.0
func (oi *OutputIngester) Stop() error
Stop flushes any remaining metrics and stops the goroutine.