Documentation ¶
Overview ¶
Internal server metrics
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Metrics ¶
type Metrics struct { // APIResponseDurationsMilliseconds is the number of milliseconds it takes to // complete API responses. // // Labels: path (request path), method (request HTTP method), // status_code (response HTTP status code) APIResponseDurationsMilliseconds *prometheus.HistogramVec // APIHandlerPanicsTotal is the number of times HTTP request handlers have paniced. // // Labels: path(request path), method( request HTTP method) APIHandlerPanicsTotal *prometheus.CounterVec // JobsRunDurationsMilliseconds is the number of milliseconds jobs run for. // // Labels: job_type (jobs.JobStartRequest.Type field), successful (0 = fail, 1 = success) JobsRunDurationsMilliseconds *prometheus.HistogramVec }
Metrics holds all the available internal metrics
func NewMetrics ¶
func NewMetrics() Metrics
NewMetrics creates a Metrics struct with all the Prometheus metrics recorders initialized
func (Metrics) StartTimer ¶
StartTimer starts a Timer for the provided Prometheus observer. Calling .Finish() on the returned timer will records the time elapsed in milliseconds.
type MetricsResponseWriter ¶
type MetricsResponseWriter struct { // ResponseWriter which will actually perform work ResponseWriter http.ResponseWriter // OnWriteHeader is a called any time ResponseWriter.WriteHeader is called OnWriteHeader OnWriteHeaderFunc }
MetricsResponseWriter wraps an net/http.ResponseWriter and records metrics when certain interface methods are called
func (MetricsResponseWriter) Header ¶
func (r MetricsResponseWriter) Header() http.Header
Header calls ResponseWriter.Header
func (MetricsResponseWriter) Write ¶
func (r MetricsResponseWriter) Write(b []byte) (int, error)
Write calls ResponseWriter.Write
func (MetricsResponseWriter) WriteHeader ¶
func (r MetricsResponseWriter) WriteHeader(code int)
WriteHeader calls ResponseWriter.WriteHeader and OnWriteHeader
type OnWriteHeaderFunc ¶
type OnWriteHeaderFunc func(code int)
OnWriteHeaderFunc is a function which will be called any time ResponseWriter.WriteHeader is called
type Timer ¶
type Timer struct {
// contains filtered or unexported fields
}
Timer measures the duration an operation and saves the result in a Prometheus observer. Time units are milliseconds.
func (Timer) Finish ¶
func (t Timer) Finish(observer prometheus.Observer)
Finish writes the duration between time.Now() and .startTime, in milliseconds, to the observer.