notify

package
v0.0.0-...-f6b5871 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: BSD-3-Clause Imports: 37 Imported by: 2

Documentation

Overview

Package notify is a package for sending notifications.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAndroidNotificationDataProvider

func NewAndroidNotificationDataProvider(commitRangeURITemplate string, notifyConfig *config.NotifyConfig) (*androidNotificationProvider, error)

NewAndroidNotificationDataProvider returns a new instance of the androidNotificationProvider.

func URLFromCommitRange

func URLFromCommitRange(commit, previousCommit provider.Commit, commitRangeURLTemplate string) string

URLFromCommitRange returns a URL that points to commit.URL or the expansion of the commitRangeURLTemplate if appropriate.

Types

type AndroidBugTemplateContext

type AndroidBugTemplateContext struct {
	// URL is the root URL of the Perf instance.
	URL string

	// DashboardUrl is the URL to view the regressing traces on the explore
	// page.
	DashboardUrl string

	// PreviousCommit is the previous commit the regression was found at.
	//
	// All commits that might be blamed for causing the regression
	// are in the range `(PreviousCommit, Commit]`, that is inclusive of
	// Commit but exclusive of PreviousCommit.
	PreviousCommit provider.Commit

	// RegressionCommit is the commit the regression was found at.
	RegressionCommit provider.Commit

	// CommitURL is a URL that points to the above Commit. The value of this URL
	// can be controlled via the `--commit_range_url` flag.
	CommitURL string

	// Alert is the configuration for the alert that found the regression.
	Alert *alerts.Alert

	// Cluster is all the information found about the regression.
	Cluster *clustering2.ClusterSummary

	// ParamSet for all the matching traces in the query.
	ParamSet paramtools.ReadOnlyParamSet

	// TraceID for the trace where regression is detected. Only available when the
	// detection is done individually and not KMeans.
	TraceID string

	// RegressionCommitLinks contain the links for the regression commit data point for the trace.
	RegressionCommitLinks map[string]string

	// PreviousCommitLinks contain the links for the commit data point before the regression for the trace.
	PreviousCommitLinks map[string]string
}

AndroidBugTemplateContext provides a struct containing data necessary for generating body and subject for android instance bugs.

func (AndroidBugTemplateContext) GetBuildIdUrlDiff

func (context AndroidBugTemplateContext) GetBuildIdUrlDiff() string

GetBuildIdUrlDiff returns a url that contains the diff between build ids for androidx.

type ChromePerfNotifier

type ChromePerfNotifier struct {
	// contains filtered or unexported fields
}

ChromeperfNotifier struct used to send regression data to chromeperf.

func NewChromePerfNotifier

func NewChromePerfNotifier(ctx context.Context, anomalyApiClient chromeperf.AnomalyApiClient) (*ChromePerfNotifier, error)

NewChromePerfNotifier returns a new ChromePerfNotifier instance.

func (*ChromePerfNotifier) ExampleSend

func (n *ChromePerfNotifier) ExampleSend(ctx context.Context, alert *alerts.Alert) error

ExampleSend is for dummy data. Do nothing!

func (*ChromePerfNotifier) RegressionFound

func (n *ChromePerfNotifier) RegressionFound(
	ctx context.Context,
	commit,
	previousCommit provider.Commit,
	alert *alerts.Alert,
	cl *clustering2.ClusterSummary,
	frame *frame.FrameResponse,
	regressionID string) (string, error)

RegressionFound implements notify.Notifier. Invoked when a new regression is detected.

func (*ChromePerfNotifier) RegressionMissing

func (n *ChromePerfNotifier) RegressionMissing(
	ctx context.Context,
	commit,
	previousCommit provider.Commit,
	alert *alerts.Alert,
	cl *clustering2.ClusterSummary,
	frame *frame.FrameResponse,
	threadingReference string) error

RegressionMissing implements notify.Notifier. Invoked when a previous regression is recovered.

func (*ChromePerfNotifier) UpdateNotification

func (n *ChromePerfNotifier) UpdateNotification(ctx context.Context, commit, previousCommit provider.Commit, alert *alerts.Alert, cl *clustering2.ClusterSummary, frame *frame.FrameResponse, notificationId string) error

UpdateRegressionNotification implements Transport.

type EmailTransport

type EmailTransport struct {
	// contains filtered or unexported fields
}

EmailTransport implements Transport using emailclient.

func NewEmailTransport

func NewEmailTransport() EmailTransport

NewEmailTransport returns a new EmailService instance.

func (EmailTransport) SendNewRegression

func (e EmailTransport) SendNewRegression(ctx context.Context, alert *alerts.Alert, body, subject string) (string, error)

SendNewRegression implements Transport.

func (EmailTransport) SendRegressionMissing

func (e EmailTransport) SendRegressionMissing(ctx context.Context, threadingReference string, alert *alerts.Alert, body, subject string) error

SendRegressionMissing implements Transport.

func (EmailTransport) UpdateRegressionNotification

func (e EmailTransport) UpdateRegressionNotification(ctx context.Context, alert *alerts.Alert, body, notificationId string) error

UpdateRegressionNotification implements Transport.

type Formatter

type Formatter interface {
	// Return body and subject.
	FormatNewRegression(ctx context.Context, commit, previousCommit provider.Commit, alert *alerts.Alert, cl *clustering2.ClusterSummary, URL string, frame *frame.FrameResponse) (string, string, error)
	FormatRegressionMissing(ctx context.Context, commit, previousCommit provider.Commit, alert *alerts.Alert, cl *clustering2.ClusterSummary, URL string, frame *frame.FrameResponse) (string, string, error)
}

Formatter has implementations for both HTML and Markdown.

type HTMLFormatter

type HTMLFormatter struct {
	// contains filtered or unexported fields
}

HTMLFormatter implements Formatter.

func NewHTMLFormatter

func NewHTMLFormatter(commitRangeURITemplate string) HTMLFormatter

NewHTMLFormatter returns a new HTMLFormatter.

func (HTMLFormatter) FormatNewRegression

func (h HTMLFormatter) FormatNewRegression(ctx context.Context, commit, previousCommit provider.Commit, alert *alerts.Alert, cl *clustering2.ClusterSummary, URL string, frame *frame.FrameResponse) (string, string, error)

FormatNewRegression implements Formatter.

func (HTMLFormatter) FormatRegressionMissing

func (h HTMLFormatter) FormatRegressionMissing(ctx context.Context, commit, previousCommit provider.Commit, alert *alerts.Alert, cl *clustering2.ClusterSummary, URL string, frame *frame.FrameResponse) (string, string, error)

FormatRegressionMissing implements Formatter.

type IssueTrackerTransport

type IssueTrackerTransport struct {
	// contains filtered or unexported fields
}

IssueTrackerTransport implements Transport using the issue tracker API.

func NewIssueTrackerTransport

func NewIssueTrackerTransport(ctx context.Context, cfg *config.NotifyConfig) (*IssueTrackerTransport, error)

NewIssueTrackerTransport returns a new IssueTrackerTransport.

func (*IssueTrackerTransport) SendNewRegression

func (t *IssueTrackerTransport) SendNewRegression(ctx context.Context, alert *alerts.Alert, body, subject string) (string, error)

SendNewRegression implements Transport.

func (*IssueTrackerTransport) SendRegressionMissing

func (t *IssueTrackerTransport) SendRegressionMissing(ctx context.Context, threadingReference string, alert *alerts.Alert, body, subject string) error

SendRegressionMissing implements Transport.

func (*IssueTrackerTransport) UpdateRegressionNotification

func (t *IssueTrackerTransport) UpdateRegressionNotification(ctx context.Context, alert *alerts.Alert, body, notificationId string) error

UpdateRegressionNotification updates the bug with a comment containing the details specified.

type MarkdownFormatter

type MarkdownFormatter struct {
	// contains filtered or unexported fields
}

MarkdownFormatter implement Formatter.

func NewMarkdownFormatter

func NewMarkdownFormatter(commitRangeURITemplate string, notifyConfig *config.NotifyConfig) (MarkdownFormatter, error)

NewMarkdownFormatter return a new MarkdownFormatter.

func (MarkdownFormatter) FormatNewRegression

func (h MarkdownFormatter) FormatNewRegression(ctx context.Context, commit, previousCommit provider.Commit, alert *alerts.Alert, cl *clustering2.ClusterSummary, URL string, frame *frame.FrameResponse) (string, string, error)

FormatNewRegression implements Formatter.

func (MarkdownFormatter) FormatNewRegressionWithContext

func (h MarkdownFormatter) FormatNewRegressionWithContext(templateContext interface{}) (string, string, error)

FormatNewRegressionWithContext formats the bug data for a new regression using the given templateContext instance.

func (MarkdownFormatter) FormatRegressionMissing

func (h MarkdownFormatter) FormatRegressionMissing(ctx context.Context, commit, previousCommit provider.Commit, alert *alerts.Alert, cl *clustering2.ClusterSummary, URL string, frame *frame.FrameResponse) (string, string, error)

FormatRegressionMissing implements Formatter.

func (MarkdownFormatter) FormatRegressionMissingWithContext

func (h MarkdownFormatter) FormatRegressionMissingWithContext(templateContext interface{}) (string, string, error)

FormatRegressionMissingWithContext formats the bug data for a missing regression using the given template context instance.

type NoopTransport

type NoopTransport struct {
}

NoopTransport implements Transport by doing nothing.

func NewNoopTransport

func NewNoopTransport() NoopTransport

NewNoopTransport returns a new EmailService instance.

func (NoopTransport) SendNewRegression

func (e NoopTransport) SendNewRegression(ctx context.Context, alert *alerts.Alert, body, subject string) (string, error)

SendNewRegression implements Transport.

func (NoopTransport) SendRegressionMissing

func (e NoopTransport) SendRegressionMissing(ctx context.Context, threadingReference string, alert *alerts.Alert, body, subject string) error

SendRegressionMissing implements Transport.

func (NoopTransport) UpdateRegressionNotification

func (e NoopTransport) UpdateRegressionNotification(ctx context.Context, alert *alerts.Alert, body, notificationId string) error

UpdateRegressionNotification implements Transport.

type NotificationDataProvider

type NotificationDataProvider interface {
	// GetNotificationDataRegressionFound returns a notificationData object for the given regression metadata.
	GetNotificationDataRegressionFound(context.Context, common.RegressionMetadata) (*common.NotificationData, error)

	// GetNotificationDataRegressionMissing returns a notificationData object for the given regression metadata.
	GetNotificationDataRegressionMissing(context.Context, common.RegressionMetadata) (*common.NotificationData, error)
}

NotificationDataProvider provides an interface to be used to perform notification data related operations.

type Notifier

type Notifier interface {
	// RegressionFound sends a notification for the given cluster found at the given commit.
	RegressionFound(ctx context.Context, commit, previousCommit provider.Commit, alert *alerts.Alert, cl *clustering2.ClusterSummary, frame *frame.FrameResponse, regressionID string) (string, error)

	// RegressionMissing sends a notification that a previous regression found for
	// the given cluster found at the given commit has disappeared after more data
	// has arrived.
	RegressionMissing(ctx context.Context, commit, previousCommit provider.Commit, alert *alerts.Alert, cl *clustering2.ClusterSummary, frame *frame.FrameResponse, threadingReference string) error

	// ExampleSend sends an example for dummy data for the given alerts.Config.
	ExampleSend(ctx context.Context, alert *alerts.Alert) error

	UpdateNotification(ctx context.Context, commit, previousCommit provider.Commit, alert *alerts.Alert, cl *clustering2.ClusterSummary, frame *frame.FrameResponse, notificationId string) error
}

Notifier provides an interface for regression notification functions

func New

func New(ctx context.Context, cfg *config.NotifyConfig, URL, commitRangeURITemplate string, traceStore tracestore.TraceStore, fs fs.FS) (Notifier, error)

New returns a Notifier of the selected type.

type TemplateContext

type TemplateContext struct {
	// URL is the root URL of the Perf instance.
	URL string

	// ViewOnDashboard is the URL to view the regressing traces on the explore
	// page.
	ViewOnDashboard string

	// PreviousCommit is the previous commit the regression was found at.
	//
	// All commits that might be blamed for causing the regression
	// are in the range `(PreviousCommit, Commit]`, that is inclusive of
	// Commit but exclusive of PreviousCommit.
	PreviousCommit provider.Commit

	// Commit is the commit the regression was found at.
	Commit provider.Commit

	// CommitURL is a URL that points to the above Commit. The value of this URL
	// can be controlled via the `--commit_range_url` flag.
	CommitURL string

	// Alert is the configuration for the alert that found the regression.
	Alert *alerts.Alert

	// Cluster is all the information found about the regression.
	Cluster *clustering2.ClusterSummary

	// ParamSet for all the matching traces.
	ParamSet paramtools.ReadOnlyParamSet
}

TemplateContext is used in expanding the message templates.

type Transport

type Transport interface {
	SendNewRegression(ctx context.Context, alert *alerts.Alert, body, subject string) (threadingReference string, err error)
	SendRegressionMissing(ctx context.Context, threadingReference string, alert *alerts.Alert, body, subject string) (err error)
	UpdateRegressionNotification(ctx context.Context, alert *alerts.Alert, body, notificationId string) (err error)
}

Transport has implementations for email, issuetracker, and the noop implementation.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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