metrics

package
v0.0.0-...-43b7830 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OtherRequestMethod string = "other"
)

Variables

View Source
var (
	ProxyUpstreamUnhealthyObservers     = newUnionObserver()
	ProxyReceiveRequestCounterObservers = newUnionObserver()
	ProxyRequestCounterObservers        = newUnionObserver()
	ProxyRequestLatenciesObservers      = newUnionObserver()
	ProxyResponseSizesObservers         = newUnionObserver()
	ProxyRequestTerminationsObservers   = newUnionObserver()
	ProxyWatcherRegisteredObservers     = newUnionObserver()
	ProxyWatcherUnregisteredObservers   = newUnionObserver()

	ProxyRateLimiterRequestCounterObservers = newUnionObserver()
	ProxyGlobalFlowControlAcquireObservers  = newUnionObserver()

	ProxyRequestInflightObservers   = newUnionObserver()
	ProxyRequestThroughputObservers = newUnionObserver()

	ProxyHandlingLatencyObservers = newUnionObserver()
)
View Source
var (
	// ValidRequestMethods are the valid request methods which we report in our metrics.
	// Any other request methods will be aggregated under 'unknown'
	ValidRequestMethods = utilsets.NewString(
		"APPLY",
		"CONNECT",
		"CREATE",
		"DELETE",
		"DELETECOLLECTION",
		"GET",
		"LIST",
		"PATCH",
		"POST",
		"PROXY",
		"PUT",
		"UPDATE",
		"WATCH",
		"WATCHLIST",
	)
)

Functions

func CleanScope

func CleanScope(requestInfo *request.RequestInfo) string

CleanScope returns the scope of the request.

func MonitorProxyRequest

func MonitorProxyRequest(req *http.Request, serverName, endpoint, flowControl string, requestInfo *request.RequestInfo, contentType string, httpCode, respSize int, elapsed time.Duration)

MonitorProxyRequest handles standard transformations for client and the reported verb and then invokes Monitor to record a request. verb must be uppercase to be backwards compatible with existing monitoring tooling.

func RecordGlobalFlowControlAcquire

func RecordGlobalFlowControlAcquire(serverName string, flowControlType string, limitMethod string, flowControl string, elapsed time.Duration)

func RecordProxyRateAndInflight

func RecordProxyRateAndInflight(rate float64, inflight int32)

func RecordProxyRequestReceived

func RecordProxyRequestReceived(req *http.Request, serverName string, requestInfo *request.RequestInfo)

func RecordProxyRequestTermination

func RecordProxyRequestTermination(req *http.Request, code int, reason, flowControl string)

RecordProxyRequestTermination records that the request was terminated early as part of a resource preservation or apiserver self-defense mechanism (e.g. timeouts, maxinflight throttling, proxyHandler errors). RecordProxyRequestTermination should only be called zero or one times per request.

func RecordProxyTraceLatency

func RecordProxyTraceLatency(traceLatencies map[string]time.Duration, serverName string, requestInfo *request.RequestInfo)

func RecordRateLimiterRequest

func RecordRateLimiterRequest(serverName string, method string, result string, flowControl string, elapsed time.Duration)

RecordRateLimiterRequest records ratelimiter requests

func RecordRequestThroughput

func RecordRequestThroughput(requestSizeTotal, responseSizeTotal int64)

func RecordUnhealthyUpstream

func RecordUnhealthyUpstream(serverName string, endpoint string, reason string)

RecordUnhealthyUpstream records that the upstream endpoint is unhealthy.

func RecordWatcherRegistered

func RecordWatcherRegistered(serverName, endpoint, resource string)

func RecordWatcherUnregistered

func RecordWatcherUnregistered(serverName, endpoint, resource string)

func Register

func Register()

Register all metrics.

Types

type MetricInfo

type MetricInfo struct {
	Request           *http.Request
	IsResourceRequest bool
	ServerName        string
	Endpoint          string
	FlowControl       string
	Verb              string
	Resource          string
	HttpCode          string
	Path              string
	Reason            string
	Stage             string
	RequestSize       int64
	ResponseSize      int64
	Latency           float64
	Rate              float64
	Inflight          float64
	TraceLatencies    map[string]time.Duration

	Method      string
	Result      string
	LimitMethod string
	Type        string
}

type MetricObserver

type MetricObserver interface {
	Observe(metric MetricInfo)
}

type UnionObserver

type UnionObserver interface {
	MetricObserver
	AddObserver(MetricObserver)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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