chromeperf

package
v0.0.0-...-0ec319e Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: BSD-3-Clause Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AlertGroupAPIName = "alert_group"
	DetailsFuncName   = "details"
	MastersKey        = "masters"
	BotsKey           = "bots"
	BenchmarksKey     = "benchmarks"
	TestsKey          = "tests"
	Subtests1Key      = "subtests_1"
	Subtests2Key      = "subtests_2"
)
View Source
const (
	AnomalyAPIName   = "anomalies"
	AddFuncName      = "add"
	FindFuncName     = "find"
	FindTimeFuncName = "find_time"
	GetFuncName      = "get"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AlertGroupApiClient

type AlertGroupApiClient interface {
	// GetAlertGroupDetails returns the alert group details for the provided group key.
	GetAlertGroupDetails(ctx context.Context, groupKey string) (*AlertGroupDetails, error)
}

AlertGroupApiClient provides an interface to interact with the alert_group api in chromeperf.

func NewAlertGroupApiClient

func NewAlertGroupApiClient(ctx context.Context) (AlertGroupApiClient, error)

NewAlertGroupApiClient returns a new instance of AlertGroupApiClient

type AlertGroupDetails

type AlertGroupDetails struct {
	GroupId           string            `json:"group_id"`
	Anomalies         map[string]string `json:"anomalies"`
	StartCommitNumber int32             `json:"start_commit"`
	EndCommitNumber   int32             `json:"end_commit"`

	// The hashes below are needed for cases where the commit numbers are
	// different in chromeperf and in the perf instance. We can use these
	// hashes to look up the correct commit number from the database.
	StartCommitHash string `json:"start_commit_hash,omitempty"`
	EndCommitHash   string `json:"end_commit_hash,omitempty"`
}

AlertGroupDetails contains data received from the alert group api.

func (*AlertGroupDetails) GetQueryParams

func (alertGroup *AlertGroupDetails) GetQueryParams(ctx context.Context) map[string][]string

GetQueryParams returns the query parameters corresponding to the alert group data.

func (*AlertGroupDetails) GetQueryParamsPerTrace

func (alertGroup *AlertGroupDetails) GetQueryParamsPerTrace(ctx context.Context) []map[string][]string

GetQueryParamsPerTrace returns an array of query parameters where each element consists of query params for a specific anomaly

type Anomaly

type Anomaly struct {
	Id            int    `json:"id"`
	TestPath      string `json:"test_path"`
	BugId         int    `json:"bug_id"`
	StartRevision int    `json:"start_revision"`
	EndRevision   int    `json:"end_revision"`

	// The hashes below are needed for cases where the commit numbers are
	// different in chromeperf and in the perf instance. We can use these
	// hashes to look up the correct commit number from the database.
	StartRevisionHash string `json:"start_revision_hash,omitempty"`
	EndRevisionHash   string `json:"end_revision_hash,omitempty"`

	IsImprovement       bool     `json:"is_improvement"`
	Recovered           bool     `json:"recovered"`
	State               string   `json:"state"`
	Statistics          string   `json:"statistic"`
	Unit                string   `json:"units"`
	DegreeOfFreedom     float64  `json:"degrees_of_freedom"`
	MedianBeforeAnomaly float64  `json:"median_before_anomaly"`
	MedianAfterAnomaly  float64  `json:"median_after_anomaly"`
	PValue              float64  `json:"p_value"`
	SegmentSizeAfter    int      `json:"segment_size_after"`
	SegmentSizeBefore   int      `json:"segment_size_before"`
	StdDevBeforeAnomaly float64  `json:"std_dev_before_anomaly"`
	TStatistics         float64  `json:"t_statistic"`
	SubscriptionName    string   `json:"subscription_name"`
	BugComponent        string   `json:"bug_component"`
	BugLabels           []string `json:"bug_labels"`
	BugCcEmails         []string `json:"bug_cc_emails"`
}

Anomaly defines the object return from Chrome Perf API.

type AnomalyApiClient

type AnomalyApiClient interface {
	// ReportRegression sends regression information to chromeperf.
	ReportRegression(ctx context.Context, testPath string, startCommitPosition int32, endCommitPosition int32, projectId string, isImprovement bool, botName string, internal bool, medianBefore float32, medianAfter float32) (*ReportRegressionResponse, error)

	// GetAnomalyFromUrlSafeKey returns the anomaly details based on the urlsafe key.
	GetAnomalyFromUrlSafeKey(ctx context.Context, key string) (map[string][]string, Anomaly, error)

	// GetAnomalies retrieves anomalies for a given set of traces within the supplied commit positions.
	GetAnomalies(ctx context.Context, traceNames []string, startCommitPosition int, endCommitPosition int) (AnomalyMap, error)

	// GetAnomaliesTimeBased retrieves anomalies for a given set of traces within the supplied commit positions.
	GetAnomaliesTimeBased(ctx context.Context, traceNames []string, startTime time.Time, endTime time.Time) (AnomalyMap, error)

	// GetAnomaliesAroundRevision retrieves traces with anomalies that were generated around a specific commit
	GetAnomaliesAroundRevision(ctx context.Context, revision int) ([]AnomalyForRevision, error)
}

AnomalyApiClient provides interface to interact with chromeperf "anomalies" api

func NewAnomalyApiClient

func NewAnomalyApiClient(ctx context.Context, git perfgit.Git) (AnomalyApiClient, error)

NewAnomalyApiClient returns a new AnomalyApiClient instance.

type AnomalyForRevision

type AnomalyForRevision struct {
	StartRevision int                 `json:"start_revision"`
	EndRevision   int                 `json:"end_revision"`
	Anomaly       Anomaly             `json:"anomaly"`
	Params        map[string][]string `json:"params"`
	TestPath      string              `json:"test_path"`
}

AnomalyForRevision defines struct to contain anomaly data for a specific revision

func (*AnomalyForRevision) GetKey

func (anomaly *AnomalyForRevision) GetKey() string

GetKey returns a string representing a key based on the params for the anomaly.

func (*AnomalyForRevision) GetParamValue

func (anomaly *AnomalyForRevision) GetParamValue(paramName string) string

GetParamValue returns the value for the given param name in the anomaly. Returns empty string if the value is not present.

func (*AnomalyForRevision) GetTestPath

func (anomaly *AnomalyForRevision) GetTestPath() string

GetTestPath returns the test path representation for the anomaly. To maintain parity with the legacy dashboard, this testpath does not include the master/bot/benchmark portion of the path.

type AnomalyMap

type AnomalyMap map[string]CommitNumberAnomalyMap

AnomalyMap is a map of CommitNumberAnomalyMap, keyed by traceId.

type ChromePerfClient

type ChromePerfClient interface {
	// SendGetRequest sends a GET request to chromeperf api with the specified parameters.
	// The url is of the format <host>/{apiName}/{functionName}?{queryParams}.
	// The response from the api is unmarshalled into the provided response object.
	SendGetRequest(ctx context.Context, apiName string, functionName string, queryParams url.Values, response interface{}) error

	// SendPostRequest sends a POST request to chromeperf api with the specified parameters.
	// The url is of the format <host>/{apiName}/{functionName}.
	// The {requestObj} is marshalled into JSON and added to the body of the http object.
	// The response from the api is unmarshalled into the provided response object.
	// {acceptedStatusCodes} is a list of HTTP response codes that are considered successful. The function will return an error if any other status code is returned.
	SendPostRequest(ctx context.Context, apiName string, functionName string, requestObj interface{}, responseObj interface{}, acceptedStatusCodes []int) error
}

ChromePerfClient defines an interface for accessing chromeperf apis.

func NewChromePerfClient

func NewChromePerfClient(ctx context.Context, urlOverride string, directCall bool) (ChromePerfClient, error)

NewChromePerfClient creates a new instance of ChromePerfClient.

type CommitNumberAnomalyMap

type CommitNumberAnomalyMap map[types.CommitNumber]Anomaly

CommitNumberAnomalyMap is a map of Anomaly, keyed by commit number.

type GetAnomaliesRequest

type GetAnomaliesRequest struct {
	Tests       []string `json:"tests,omitempty"`
	MaxRevision string   `json:"max_revision,omitempty"`
	MinRevision string   `json:"min_revision,omitempty"`
	Revision    int      `json:"revision,omitempty"`
}

GetAnomaliesRequest struct to request anomalies from the chromeperf api. The parameters can be one of below described. 1. Revision: Retrieves anomalies around that revision number. 2. Tests-MinRevision-MaxRevision: Retrieves anomalies for the given set of tests between the min and max revisions

type GetAnomaliesResponse

type GetAnomaliesResponse struct {
	Anomalies map[string][]Anomaly `json:"anomalies"`
}

type GetAnomaliesTimeBasedRequest

type GetAnomaliesTimeBasedRequest struct {
	Tests     []string  `json:"tests,omitempty"`
	StartTime time.Time `json:"start_time,omitempty"`
	EndTime   time.Time `json:"end_time,omitempty"`
}

type ReportRegressionRequest

type ReportRegressionRequest struct {
	StartRevision       int32   `json:"start_revision"`
	EndRevision         int32   `json:"end_revision"`
	ProjectID           string  `json:"project_id"`
	TestPath            string  `json:"test_path"`
	IsImprovement       bool    `json:"is_improvement"`
	BotName             string  `json:"bot_name"`
	Internal            bool    `json:"internal_only"`
	MedianBeforeAnomaly float32 `json:"median_before_anomaly"`
	MedianAfterAnomaly  float32 `json:"median_after_anomaly"`
}

ReportRegressionRequest provides a struct for the data that is sent over to chromeperf when a regression is detected.

type ReportRegressionResponse

type ReportRegressionResponse struct {
	AnomalyId    string `json:"anomaly_id"`
	AlertGroupId string `json:"alert_group_id"`
}

ReportRegressionResponse provides a struct to hold the response data returned by the add anomalies api.

type RevisionInfo

type RevisionInfo struct {
	Master        string   `json:"master"`
	Bot           string   `json:"bot"`
	Benchmark     string   `json:"benchmark"`
	StartRevision int      `json:"start_revision"`
	EndRevision   int      `json:"end_revision"`
	StartTime     int64    `json:"start_time"`
	EndTime       int64    `json:"end_time"`
	TestPath      string   `json:"test"`
	IsImprovement bool     `json:"is_improvement"`
	BugId         string   `json:"bug_id"`
	ExploreUrl    string   `json:"explore_url"`
	Query         string   `json:"query"`
	AnomalyIds    []string `json:"anomaly_ids"`
}

RevisionInfo defines struct to contain revision information

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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