engine

package
v0.0.0-...-deba56b Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2023 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package engine contains the internal metrics engine responsible for aggregating metrics during the test and evaluating thresholds against them.

Index

Constants

View Source
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

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

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

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

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

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

func (oi *OutputIngester) Description() string

Description returns a human-readable description of the output.

func (*OutputIngester) Start

func (oi *OutputIngester) Start() error

Start the engine by initializing a new output.PeriodicFlusher

func (*OutputIngester) Stop

func (oi *OutputIngester) Stop() error

Stop flushes any remaining metrics and stops the goroutine.

Jump to

Keyboard shortcuts

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