metrics

package
v1.2.0-alpha.5....-8a98da9 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2018 License: Apache-2.0, Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ReadOnlyKind is a string identifying read only request kind
	ReadOnlyKind = "readOnly"
	// MutatingKind is a string identifying mutating request kind
	MutatingKind = "mutating"
)

Variables

View Source
var (

	// DroppedRequests is a number of requests dropped with 'Try again later' reponse"
	DroppedRequests = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Name: "apiserver_dropped_requests",
			Help: "Number of requests dropped with 'Try again later' reponse",
		},
		[]string{"requestKind"},
	)
)

Functions

func InstrumentRouteFunc

func InstrumentRouteFunc(verb, resource, subresource, scope string, routeFunc restful.RouteFunction) restful.RouteFunction

InstrumentRouteFunc works like Prometheus' InstrumentHandlerFunc but wraps the go-restful RouteFunction instead of a HandlerFunc

func MonitorRequest

func MonitorRequest(req *http.Request, verb, resource, subresource, scope, 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

func Record(req *http.Request, requestInfo *request.RequestInfo, 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

func RecordLongRunning(req *http.Request, requestInfo *request.RequestInfo, 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 Reset

func Reset()

func UpdateInflightRequestMetrics

func UpdateInflightRequestMetrics(nonmutating, mutating int)

Types

type ResponseWriterDelegator

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

func (r *ResponseWriterDelegator) ContentLength() int

func (*ResponseWriterDelegator) Status

func (r *ResponseWriterDelegator) Status() int

func (*ResponseWriterDelegator) Write

func (r *ResponseWriterDelegator) Write(b []byte) (int, error)

func (*ResponseWriterDelegator) WriteHeader

func (r *ResponseWriterDelegator) WriteHeader(code int)

Jump to

Keyboard shortcuts

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