http

package
v0.0.0-...-8939947 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2022 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RunDurationMetricName is the name of the metric for test and benchmark run
	// durations.
	RunDurationMetricName = "run_duration_s"

	// RunLastMetricName is the name of the metric for the test and benchmark last
	// run timestamp.
	RunLastMetricName = "run_last_timestamp"
)

Variables

View Source
var RunDurationMetric = prometheus.NewHistogramVec(
	prometheus.HistogramOpts{
		Namespace: "tester",
		Subsystem: "tb",
		Name:      RunDurationMetricName,
		Help:      "Amount of time tests or benchmarks take.",
		Buckets: []float64{

			0.001, 0.01,
			0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0,
			1.25, 1.5, 1.75, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5,
			6, 7, 8, 9, 10, 15, 20, 25, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120,
			180, 240, 300, 360, 420, 480, 540, 600, 660, 720, 780, 840, 900,
		},
	},
	[]string{"name", "state"},
)

RunDurationMetric is the the metric for test and benchmark run durations.

View Source
var RunLastMetric = prometheus.NewGaugeVec(
	prometheus.GaugeOpts{
		Namespace: "testr",
		Subsystem: "tb",
		Name:      RunLastMetricName,
		Help:      "Timestamp of the last run for a test or benchmark.",
	},
	[]string{"name", "state"},
)

RunLastMetric is the the metric for test and benchmark last run timestamps.

Functions

func LogHandlerFunc

func LogHandlerFunc(next http.HandlerFunc) http.HandlerFunc

LogHandlerFunc logs request/response information.

Types

type APIHandler

type APIHandler struct {
	http.Handler
	// contains filtered or unexported fields
}

APIHandler is the http handler for presenting the API.

func NewAPIHandler

func NewAPIHandler(db db.DB, packages []*tester.Package, opts ...Option) *APIHandler

NewAPIHandler constructs a new `APIHandler`.

func (*APIHandler) ServeHTTP

func (h *APIHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ClaimRunRequest

type ClaimRunRequest struct {
	PackageWhitelist []string `json:"package_whitelist"`
	PackageBlacklist []string `json:"package_blacklist"`
}

type Option

type Option func(*options)

Option is used to inject dependencies into a Server on creation.

func WithAPIKey

func WithAPIKey(key string) Option

WithAPIKey allows configuring a symmetric key for api auth.

func WithAlertManager

func WithAlertManager(am *alerting.AlertManager) Option

WithAlertManager allows configuring a custom alert manager.

func WithSlackApp

func WithSlackApp(app *slack.App) Option

WithSlackApp allows configuring a slack app integration.

type ResponseInspectingWriter

type ResponseInspectingWriter struct {
	http.ResponseWriter
	Status int
}

ResponseInspectingWriter is an http.ResponseWriter that captures response info.

func (*ResponseInspectingWriter) Write

func (w *ResponseInspectingWriter) Write(p []byte) (int, error)

Write wraps the method for writing response bodies..

func (*ResponseInspectingWriter) WriteHeader

func (w *ResponseInspectingWriter) WriteHeader(s int)

WriteHeader wraps the method capturing the response status code.

type UIHandler

type UIHandler struct {
	http.Handler
	// contains filtered or unexported fields
}

UIHandler is the http handler for presenting the web UI.

func NewUIHandler

func NewUIHandler(db db.DB, packages []*tester.Package) *UIHandler

NewUIHandler constructs a new `UIHandler`.

func (*UIHandler) ExecuteTemplate

func (s *UIHandler) ExecuteTemplate(name string, w io.Writer, value interface{}) error

ExecuteTemplate runs the given template with the value

func (*UIHandler) LoadSummaries

func (h *UIHandler) LoadSummaries(ctx context.Context) (packages []string, month, day, hour []*tester.RunSummary, err error)

func (*UIHandler) Render

func (h *UIHandler) Render(w http.ResponseWriter, r *http.Request, name string, value interface{})

func (*UIHandler) RenderError

func (h *UIHandler) RenderError(w http.ResponseWriter, r *http.Request, err error, status int)

func (*UIHandler) ServeHTTP

func (h *UIHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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