Documentation
¶
Overview ¶
Package observability implements various observability handlers for the API servers
Index ¶
Constants ¶
const ( // MetricSubsystem is the subsystem for the metric MetricSubsystem = "api_server" // MetricName is the name of the metric MetricName = "request_duration_seconds" )
Variables ¶
var CaptureRouteTemplateMiddleware mux.MiddlewareFunc = CaptureRouteTemplateMiddlewareWithPrefix("")
When the router is mounted under http.StripPrefix, use CaptureRouteTemplateMiddlewareWithPrefix instead to preserve the full path in the metric tag.
Functions ¶
func CaptureRouteTemplateMiddlewareWithPrefix ¶
func CaptureRouteTemplateMiddlewareWithPrefix(prefix string) mux.MiddlewareFunc
CaptureRouteTemplateMiddlewareWithPrefix returns a gorilla/mux middleware that captures the matched route template and prepends prefix to it. Use this when the router is mounted via http.StripPrefix so that the full request path is reflected in the metric tag.
Must be registered via gorilla/mux Router.Use() so that it runs inside the routing context where mux.CurrentRoute returns the matched route.
func LogResponseHandler ¶
func LogResponseHandler(servername string) mux.MiddlewareFunc
LogResponseHandler is a middleware that logs the response code and other various information about the request
Types ¶
type TelemetryMiddlewareFactory ¶
type TelemetryMiddlewareFactory interface {
Middleware(serverName string) mux.MiddlewareFunc
}
TelemetryMiddlewareFactory creates a telemetry middleware tagged with a given server name
func NewTelemetryMiddlewareFactory ¶
func NewTelemetryMiddlewareFactory(telemetry telemetry.Component, authTagGetter func(r *http.Request) string) TelemetryMiddlewareFactory
NewTelemetryMiddlewareFactory creates a new TelemetryMiddlewareFactory
This function must be called only once for a given telemetry Component, as it creates a new metric, and Prometheus panics if the same metric is registered twice.