metrics

package
v0.67.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetChiPathPattern

func GetChiPathPattern(ctx context.Context) string

GetChiPathPattern will use the chi context to return the Route Pattern associated with the provided requests context.

func Handler

func Handler(registry *prometheus.Registry) http.Handler

func NewHTTPServerMetricsMiddleware

func NewHTTPServerMetricsMiddleware(registry *prometheus.Registry, serviceName string,
	getPathPattern func(ctx context.Context) string) func(next http.Handler) http.Handler

NewHTTPServerMetricsMiddleware returns a new Prometheus Middleware handler

Types

type Middleware

type Middleware struct {
	// contains filtered or unexported fields
}

Middleware is a handler which exposes prometheus metrics. Requests will log the total number of requests partitioned by code, status and path. Latency will log the total duration of requests partitioned by code, status and path. getPathPattern allows you to pass a function which will group paths by specified patterns. If not value is assigned, the requests and latency will be partitioned by the standalone path on the incoming request.

func (*Middleware) MonitorMetrics

func (m *Middleware) MonitorMetrics(next http.Handler) http.Handler

MonitorMetrics returns a http.Handler which will monitor the incoming request metrics and update the prometheus metric values.

type ProxyResponseWriter

type ProxyResponseWriter interface {
	http.ResponseWriter
	Status() int
}

ProxyResponseWriter is a proxy for a http.ResponseWriter allowing you to access the various parts of the response at a later date.

func NewStatusResponseWriter

func NewStatusResponseWriter(w http.ResponseWriter) ProxyResponseWriter

NewStatusResponseWriter returns a ProxyResponseWriter which allows us to access the outgoing response status.

type StatusResponseWriter

type StatusResponseWriter struct {
	http.ResponseWriter
	// contains filtered or unexported fields
}

StatusResponseWriter implements the http.ResponseWriter interface and allows us access to the response status through the .Status() function.

func (*StatusResponseWriter) Status

func (w *StatusResponseWriter) Status() int

Status returns the status assigned to the outgoing http response.

func (*StatusResponseWriter) Write

func (w *StatusResponseWriter) Write(data []byte) (int, error)

Write is a wrapper around the ResponseWriter.Write function call which checks to see if the Status has been written, and defaults to http.StatusOK if not.

func (*StatusResponseWriter) WriteHeader

func (w *StatusResponseWriter) WriteHeader(code int)

WriteHeader captures the assigned response code for access at a later time, and writes the response header accordingly.

Jump to

Keyboard shortcuts

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