requestmeta

package
v11.1.4-modfix Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2024 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TeamAlerting = "alerting"
	TeamAuth     = "auth"
	TeamBackend  = "backend"
)

Variables

This section is empty.

Functions

func SetOwner

func SetOwner(team string) web.Handler

SetOwner returns an `web.Handler` that sets the team name for an request.

func SetRequestMetaData

func SetRequestMetaData(ctx context.Context, rmd RequestMetaData) context.Context

SetRequestMetaData sets the request metadata for the context.

func SetSLOGroup

func SetSLOGroup(lvl SLOGroup) web.Handler

SetSLOGroup creates an middleware that sets the SLOGroup for the request

func SetupRequestMetadata

func SetupRequestMetadata() web.Middleware

SetupRequestMetadata injects defaul request metadata values on the request context.

func WithDownstreamStatusSource

func WithDownstreamStatusSource(ctx context.Context)

WithDownstreamStatusSource sets the StatusSource field of the RequestMetaData for the context to StatusSourceDownstream.

func WithStatusSource

func WithStatusSource(ctx context.Context, statusCode int)

WithStatusSource sets the StatusSource field of the RequestMetaData for the context based on the provided statusCode. If statusCode >= 500 then StatusSourceDownstream. If statusCode < 500 then StatusSourceServer.

Types

type RequestMetaData

type RequestMetaData struct {
	Team         string
	StatusSource StatusSource
	SLOGroup     SLOGroup
}

func GetRequestMetaData

func GetRequestMetaData(ctx context.Context) *RequestMetaData

GetRequestMetaData returns the request metadata for the context. if request metadata is missing it will return the default values.

type SLOGroup

type SLOGroup string
const (
	// SLOGroupHighFast is the default slo group for handlers in Grafana
	// Most handlers should respond quickly
	SLOGroupHighFast SLOGroup = "high-fast"

	// SLOGroupHighMedium is used for handlers that might take some
	// time to respond.
	SLOGroupHighMedium SLOGroup = "high-medium"

	// SLOGroupHighSlow is used by handlers that proxies requests downstream.
	// We expect an high successrate but without latency garantess
	SLOGroupHighSlow SLOGroup = "high-slow"

	// SLOGroupLow should only be used for experimental features
	// that might not be stable enough for our normal SLO
	SLOGroupLow SLOGroup = "low"

	// SLOGroupNone means that errors are expect for this handler and
	// it should not be included in the SLO.
	SLOGroupNone SLOGroup = "none"
)

type StatusSource

type StatusSource string
const (
	StatusSourceServer     StatusSource = "server"
	StatusSourceDownstream StatusSource = "downstream"
)

Jump to

Keyboard shortcuts

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