regression

package
v0.0.0-...-8cb1d9c Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: BSD-3-Clause Imports: 25 Imported by: 4

Documentation

Overview

Package regression provides for tracking Perf regressions.

Index

Constants

View Source
const (
	// None means there is no regression.
	None Status = ""

	// Positive means this change in performance is OK/expected.
	Positive Status = "positive"

	// Negative means this regression is a bug.
	Negative Status = "negative"

	// Untriaged means the regression has not been triaged.
	Untriaged Status = "untriaged"

	// Available cluster types in regression2
	HighClusterType ClusterType = "high"
	LowClusterType  ClusterType = "low"
	NoneClusterType ClusterType = "none"
)

Status constants.

Variables

AllProcessState is a list of all ProcessState possible values.

AllStatus is a slice of all values of type Status.

View Source
var ErrNoClusterFound = errors.New("No Cluster.")

Functions

func ProcessRegressions

func ProcessRegressions(ctx context.Context,
	req *RegressionDetectionRequest,
	detectorResponseProcessor DetectorResponseProcessor,
	perfGit perfgit.Git,
	shortcutStore shortcut.Store,
	dfBuilder dataframe.DataFrameBuilder,
	ps paramtools.ReadOnlyParamSet,
	expandBaseRequest BaseAlertHandling,
	iteration Iteration,
	anomalyConfig config.AnomalyConfig,
) error

ProcessRegressions detects regressions given the RegressionDetectionRequest.

func StepFit

func StepFit(ctx context.Context, df *dataframe.DataFrame, k int, stddevThreshold float32, progress clustering2.Progress, interesting float32, stepDetection types.StepDetection) (*clustering2.ClusterSummaries, error)

StepFit finds regressions by looking at each trace individually and seeing if that looks like a regression.

Types

type AllRegressionsForCommit

type AllRegressionsForCommit struct {
	ByAlertID map[string]*Regression `json:"by_query"`
	// contains filtered or unexported fields
}

AllRegressionsForCommit is a map[alertid]Regression.

func New

New returns a new *Regressions.

type BaseAlertHandling

type BaseAlertHandling int

BaseAlertHandling determines how Alerts should be handled by ProcessRegressions.

const (
	// ExpandBaseAlertByGroupBy means that a single Alert should be turned into
	// multiple Alerts based on the GroupBy settings in the Alert.
	ExpandBaseAlertByGroupBy BaseAlertHandling = iota

	// DoNotExpandBaseAlertByGroupBy means that the Alert should not be expanded
	// into multiple Alerts even if it has a non-empty GroupBy value.
	DoNotExpandBaseAlertByGroupBy
)

type ClusterType

type ClusterType string

ClusterType is used to denote type of cluster in regression2 schema.

type DetectorResponseProcessor

type DetectorResponseProcessor func(context.Context, *RegressionDetectionRequest, []*RegressionDetectionResponse, string)

DetectorResponseProcessor is a callback that is called with RegressionDetectionResponses as a RegressionDetectionRequest is being processed.

type FullSummary

type FullSummary struct {
	Summary clustering2.ClusterSummary `json:"summary"`
	Triage  TriageStatus               `json:"triage"`
	Frame   frame.FrameResponse        `json:"frame"`
}

FullSummary describes a single regression.

type Iteration

type Iteration int

Iteration controls how ProcessRegressions deals with errors as it iterates across all the DataFrames.

const (
	// ContinueOnError causes the error to be ignored and iteration continues.
	ContinueOnError Iteration = iota

	// ReturnOnError halts the iteration and returns.
	ReturnOnError
)

type ParamsetProvider

type ParamsetProvider func() paramtools.ReadOnlyParamSet

ParamsetProvider is a function that's called to return the current paramset.

type ProcessState

type ProcessState string

ProcessState is the state of a RegressionDetectionProcess.

const (
	// ProcessRunning means the process is still running.
	ProcessRunning ProcessState = "Running"

	// ProcessSuccess means the process has finished successfully.
	ProcessSuccess ProcessState = "Success"

	// ProcessError means the process has ended on an error.
	ProcessError ProcessState = "Error"
)

type Regression

type Regression struct {
	Low        *clustering2.ClusterSummary `json:"low"`   // Can be nil.
	High       *clustering2.ClusterSummary `json:"high"`  // Can be nil.
	Frame      *frame.FrameResponse        `json:"frame"` // Describes the Low and High ClusterSummary's.
	LowStatus  TriageStatus                `json:"low_status"`
	HighStatus TriageStatus                `json:"high_status"`

	// The fields below are only to be used with the regression2 schema.
	Id               string             `json:"id"`
	CommitNumber     types.CommitNumber `json:"commit_number"`
	PrevCommitNumber types.CommitNumber `json:"prev_commit_number"`
	AlertId          int64              `json:"alert_id"`
	CreationTime     time.Time          `json:"creation_time"`
	MedianBefore     float32            `json:"median_before"`
	MedianAfter      float32            `json:"median_after"`
	IsImprovement    bool               `json:"is_improvement"`
}

Regression tracks the status of the Low and High regression clusters, if they exist for a given CommitID and alertid.

Note that Low and High can be nil if no regression has been found in that direction.

TODO(jcgregorio) Now that we can search for regressions using GroupBy it is possible that Frame will only be valid for Low or High. Fix by refactoring Regression.

func NewRegression

func NewRegression() *Regression

NewRegression returns a new *Regression.

func RegressionFromClusterResponse

func RegressionFromClusterResponse(ctx context.Context, resp *RegressionDetectionResponse, cfg *alerts.Alert, perfGit perfgit.Git) (provider.Commit, *Regression, error)

RegressionFromClusterResponse returns the commit for the regression along with the *Regression.

func (*Regression) GetClusterTypeAndSummaryAndTriageStatus

func (r *Regression) GetClusterTypeAndSummaryAndTriageStatus() (ClusterType, *clustering2.ClusterSummary, TriageStatus)

GetClusterTypeAndSummaryAndTriageStatus returns the cluster type, cluster summary and triage status objects for the regression.

func (*Regression) Merge

func (r *Regression) Merge(rhs *Regression) *Regression

Merge the results from rhs into this Regression.

func (*Regression) Triaged

func (r *Regression) Triaged() bool

Triaged returns true if triaged.

type RegressionDetectionRequest

type RegressionDetectionRequest struct {
	Alert  *alerts.Alert `json:"alert"`
	Domain types.Domain  `json:"domain"`

	// Step/TotalQueries is the current percent of all the queries that have been processed.
	Step int `json:"step"`

	// TotalQueries is the number of sub-queries to be processed based on the
	// GroupBy setting in the Alert.
	TotalQueries int `json:"total_queries"`

	// Progress of the detection request.
	Progress progress.Progress `json:"-"`
	// contains filtered or unexported fields
}

RegressionDetectionRequest is all the info needed to start a clustering run, an Alert and the Domain over which to run that Alert.

func NewRegressionDetectionRequest

func NewRegressionDetectionRequest() *RegressionDetectionRequest

NewRegressionDetectionRequest returns a new RegressionDetectionRequest.

func (*RegressionDetectionRequest) Query

Query returns the query that the RegressionDetectionRequest process is running.

Note that it may be more specific than the Alert.Query if the Alert has a non-empty GroupBy value.

func (*RegressionDetectionRequest) SetQuery

func (r *RegressionDetectionRequest) SetQuery(q string)

SetQuery sets a more refined query for the RegressionDetectionRequest.

type RegressionDetectionResponse

type RegressionDetectionResponse struct {
	Summary *clustering2.ClusterSummaries `json:"summary"`
	Frame   *frame.FrameResponse          `json:"frame"`
}

RegressionDetectionResponse is the response from running a RegressionDetectionRequest.

type Status

type Status string

Status is used in TriageStatus.

type Store

type Store interface {
	// Range returns a map from types.CommitNumber to *Regressions that exist in the
	// given range of commits. Note that if begin==end that results
	// will be returned for begin.
	Range(ctx context.Context, begin, end types.CommitNumber) (map[types.CommitNumber]*AllRegressionsForCommit, error)

	// SetHigh sets the ClusterSummary for a high regression at the given commit and alertID.
	SetHigh(ctx context.Context, commitNumber types.CommitNumber, alertID string, df *frame.FrameResponse, high *clustering2.ClusterSummary) (bool, error)

	// SetLow sets the ClusterSummary for a low regression at the given commit and alertID.
	SetLow(ctx context.Context, commitNumber types.CommitNumber, alertID string, df *frame.FrameResponse, low *clustering2.ClusterSummary) (bool, error)

	// TriageLow sets the triage status for the low cluster at the given commit and alertID.
	TriageLow(ctx context.Context, commitNumber types.CommitNumber, alertID string, tr TriageStatus) error

	// TriageHigh sets the triage status for the high cluster at the given commit and alertID.
	TriageHigh(ctx context.Context, commitNumber types.CommitNumber, alertID string, tr TriageStatus) error

	// Write the Regressions to the store. The provided 'regressions' maps from
	// types.CommitNumber to all the regressions for that commit.
	Write(ctx context.Context, regressions map[types.CommitNumber]*AllRegressionsForCommit) error
}

Store persists Regressions.

type TriageStatus

type TriageStatus struct {
	Status  Status `json:"status"`
	Message string `json:"message"`
}

TriageStatus is the status of a found regression.

Directories

Path Synopsis
Package continuous looks for Regressions in the background based on the new data arriving and the currently configured Alerts.
Package continuous looks for Regressions in the background based on the new data arriving and the currently configured Alerts.
Package regressiontest has common utility funcs for testing the regression package.
Package regressiontest has common utility funcs for testing the regression package.
Package sqlregressionstore implements the regression.Store interface on an SQL database backend.
Package sqlregressionstore implements the regression.Store interface on an SQL database backend.

Jump to

Keyboard shortcuts

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