Documentation ¶
Index ¶
- Constants
- Variables
- func CleanScope(requestInfo *request.RequestInfo) string
- func InstrumentHandlerFunc(verb, group, version, resource, subresource, scope, component string, ...) http.HandlerFunc
- func InstrumentRouteFunc(verb, group, version, resource, subresource, scope, component string, ...) restful.RouteFunction
- func MonitorRequest(req *http.Request, ...)
- func Record(req *http.Request, requestInfo *request.RequestInfo, ...)
- func RecordLongRunning(req *http.Request, requestInfo *request.RequestInfo, component string, ...)
- func Register()
- func Reset()
- func UpdateInflightRequestMetrics(nonmutating, mutating int)
- type ResponseWriterDelegator
Constants ¶
const ( // ReadOnlyKind is a string identifying read only request kind ReadOnlyKind = "readOnly" // MutatingKind is a string identifying mutating request kind MutatingKind = "mutating" )
const (
APIServerComponent string = "apiserver"
)
Variables ¶
var ( // DroppedRequests is a number of requests dropped with 'Try again later' response" DroppedRequests = prometheus.NewCounterVec( prometheus.CounterOpts{ Name: "apiserver_dropped_requests_total", Help: "Number of requests dropped with 'Try again later' response", }, []string{"requestKind"}, ) DeprecatedDroppedRequests = prometheus.NewCounterVec( prometheus.CounterOpts{ Name: "apiserver_dropped_requests", Help: "(Deprecated) Number of requests dropped with 'Try again later' response", }, []string{"requestKind"}, ) // RegisteredWatchers is a number of currently registered watchers splitted by resource. RegisteredWatchers = prometheus.NewGaugeVec( prometheus.GaugeOpts{ Name: "apiserver_registered_watchers", Help: "Number of currently registered watchers for a given resources", }, []string{"group", "version", "kind"}, ) )
Functions ¶
func CleanScope ¶ added in v1.10.0
func CleanScope(requestInfo *request.RequestInfo) string
CleanScope returns the scope of the request.
func InstrumentHandlerFunc ¶ added in v1.10.0
func InstrumentHandlerFunc(verb, group, version, resource, subresource, scope, component string, handler http.HandlerFunc) http.HandlerFunc
InstrumentHandlerFunc works like Prometheus' InstrumentHandlerFunc but adds some Kubernetes endpoint specific information.
func InstrumentRouteFunc ¶
func InstrumentRouteFunc(verb, group, version, resource, subresource, scope, component string, routeFunc restful.RouteFunction) restful.RouteFunction
InstrumentRouteFunc works like Prometheus' InstrumentHandlerFunc but wraps the go-restful RouteFunction instead of a HandlerFunc plus some Kubernetes endpoint specific information.
func MonitorRequest ¶ added in v1.8.0
func MonitorRequest(req *http.Request, verb, group, version, resource, subresource, scope, component, contentType string, httpCode, respSize int, elapsed time.Duration)
MonitorRequest 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 Record ¶ added in v1.9.0
func Record(req *http.Request, requestInfo *request.RequestInfo, component, contentType string, code int, responseSizeInBytes int, elapsed time.Duration)
Record records a single request to the standard metrics endpoints. For use by handlers that perform their own processing. All API paths should use InstrumentRouteFunc implicitly. Use this instead of MonitorRequest if you already have a RequestInfo object.
func RecordLongRunning ¶ added in v1.9.0
func RecordLongRunning(req *http.Request, requestInfo *request.RequestInfo, component string, fn func())
RecordLongRunning tracks the execution of a long running request against the API server. It provides an accurate count of the total number of open long running requests. requestInfo may be nil if the caller is not in the normal request flow.
func UpdateInflightRequestMetrics ¶ added in v1.8.8
func UpdateInflightRequestMetrics(nonmutating, mutating int)
Types ¶
type ResponseWriterDelegator ¶ added in v1.8.0
type ResponseWriterDelegator struct { http.ResponseWriter // contains filtered or unexported fields }
ResponseWriterDelegator interface wraps http.ResponseWriter to additionally record content-length, status-code, etc.
func (*ResponseWriterDelegator) ContentLength ¶ added in v1.8.0
func (r *ResponseWriterDelegator) ContentLength() int
func (*ResponseWriterDelegator) Status ¶ added in v1.8.0
func (r *ResponseWriterDelegator) Status() int
func (*ResponseWriterDelegator) Write ¶ added in v1.8.0
func (r *ResponseWriterDelegator) Write(b []byte) (int, error)
func (*ResponseWriterDelegator) WriteHeader ¶ added in v1.8.0
func (r *ResponseWriterDelegator) WriteHeader(code int)