Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ResponseTimeHeader = "X-Response-Time"
ResponseTimeHeader is the header name of response time. Change it if you use something different
Functions ¶
func RequestDuration ¶
func RequestDuration(reg prometheus.Registerer) func(http.Handler) http.Handler
RequestDuration adds a middleware to observe request durations and report to prometheus with the fully qualified name http_request_duration_seconds and labels for the status codes, method and the request path. Note that this handler only works if ResponseTime middleware is already Used. Also ensure it's used before any middleware that calls ResponseWriter.Write.
func ResponseTime ¶
ResponseTime adds a "X-Response-Time" header once the handler writes the header of the response. Ensure to Use this middleware before any middleware that Write.
Types ¶
type TimedResponseWriter ¶
type TimedResponseWriter interface { http.ResponseWriter Code() int Duration() time.Duration }
TimedResponseWriter is a wrapper around the http.ResponseWriter allowing users to track the processing time of an handler.