handler

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2021 License: BSD-2-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	PromPanicsTotal = promauto.NewCounter(
		prometheus.CounterOpts{
			Name: "http_panics_total",
			Help: "Total number of HTTP requests that triggered a panic().",
		},
	)
	PromRequestsTotal = promauto.NewCounterVec(
		prometheus.CounterOpts{
			Name: "http_requests_total",
			Help: "Total number of HTTP requests by status code.",
		},
		[]string{"code"},
	)
	PromLatencyTotal = promauto.NewCounterVec(
		prometheus.CounterOpts{
			Name: "http_latency_total",
			Help: "Total number of wall-time seconds spent on handling HTTP responses by status code.",
		},
		[]string{"code"},
	)
	PromRecvBytesTotal = promauto.NewCounterVec(
		prometheus.CounterOpts{
			Name: "http_recv_bytes_total",
			Help: "Total number of bytes received in HTTP requests by status code.",
		},
		[]string{"code"},
	)
	PromSendBytesTotal = promauto.NewCounterVec(
		prometheus.CounterOpts{
			Name: "http_send_bytes_total",
			Help: "Total number of bytes sent in HTTP responses by status code.",
		},
		[]string{"code"},
	)
	PromLatencyHist = promauto.NewHistogram(
		prometheus.HistogramOpts{
			Name:    "http_latency_seconds_hist",
			Help:    "Histogram of HTTP request latency.",
			Buckets: []float64{0.005, 0.010, 0.020, 0.050, 0.100, 0.200, 0.500, 1.000, 2.000, 5.000, 10.000},
		},
	)
	PromRecvBytesHist = promauto.NewHistogram(
		prometheus.HistogramOpts{
			Name:    "http_recv_bytes_hist",
			Help:    "Histogram of HTTP request size.",
			Buckets: prometheus.ExponentialBuckets(1024, 4.0, 6),
		},
	)
	PromSendBytesHist = promauto.NewHistogram(
		prometheus.HistogramOpts{
			Name:    "http_send_bytes_hist",
			Help:    "Histogram of HTTP response size.",
			Buckets: prometheus.ExponentialBuckets(1024, 4.0, 6),
		},
	)
)
View Source
var OnPanic func(error) = DefaultOnPanic

Functions

func DefaultOnPanic

func DefaultOnPanic(err error)

Types

type Adaptor

type Adaptor struct {
	Inner Handler
}

func (Adaptor) ServeHTTP

func (a Adaptor) ServeHTTP(w http.ResponseWriter, req *http.Request)

type Handler

type Handler interface {
	Handle(r *http.Request) response.Response
}

type HandlerFunc

type HandlerFunc func(*http.Request) response.Response

func (HandlerFunc) Handle

func (fn HandlerFunc) Handle(req *http.Request) response.Response

type PanicError

type PanicError struct {
	Value interface{}
}

func (PanicError) Error

func (err PanicError) Error() string

Jump to

Keyboard shortcuts

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