Documentation
¶
Index ¶
- Constants
- Variables
- func CounterHandler(h http.Handler) http.Handler
- func ObserveResponseSize(r *http.Request) int
- func RequestDurationHandler(version string, next http.Handler) http.Handler
- func TrackerHandler(h http.Handler, tracker *Tracker, userFn func(r *http.Request) string, ...) http.Handler
- func TrackerStatsHandler(tracker *Tracker) http.Handler
- type Prefix
- type REDTracker
- type Stats
- type Tracker
Constants ¶
View Source
const ( OK string = "ok" Err string = "err" )
Variables ¶
View Source
var ( StatusTotal = expvar.NewMap("status_total") RequestsTotal = expvar.NewMap("requests_total") ErrorsTotal = expvar.NewMap("errors_total") )
View Source
var ( InFlightGauge = prometheus.NewGauge( prometheus.GaugeOpts{ Name: "in_flight_requests", Help: "A gauge of requests currently being served by the wrapped handler.", }, ) // RequestDuration is partitioned by the HTTP method and handler. It uses custom // buckets based on the expected request duration. RequestDuration = prometheus.NewHistogramVec( prometheus.HistogramOpts{ Name: "request_duration_seconds", Help: "A histogram of latencies for requests.", Buckets: prometheus.DefBuckets, }, []string{"method", "path", "status", "version"}, ) // ResponseSize has no labels, making it a zero-dimensional // ObserverVec. ResponseSize = prometheus.NewHistogramVec( prometheus.HistogramOpts{ Name: "response_size_bytes", Help: "A histogram of response sizes for requests.", Buckets: []float64{200, 500, 900, 1500}, }, []string{}, ) RED = prometheus.NewHistogramVec( prometheus.HistogramOpts{ Name: "red", Help: "RED metrics", Buckets: prometheus.DefBuckets, }, []string{"service", "action", "status"}, ) )
Functions ¶
func CounterHandler ¶
CounterHandler tracks the success and error count. Install the expvar.Handler: mux.Handle("GET /debug/vars", expvar.Handler())
func ObserveResponseSize ¶
func RequestDurationHandler ¶
func TrackerHandler ¶
func TrackerStatsHandler ¶
Types ¶
type REDTracker ¶
func NewRED ¶
func NewRED(service, action string) *REDTracker
func (*REDTracker) Done ¶
func (r *REDTracker) Done()
func (*REDTracker) Fail ¶
func (r *REDTracker) Fail()
func (*REDTracker) SetStatus ¶
func (r *REDTracker) SetStatus(status string)
Click to show internal directories.
Click to hide internal directories.