Documentation ¶
Overview ¶
Package httpprom provides prometheus metrics for HTTP servers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Middleware ¶ added in v0.2.0
type Middleware struct {
// contains filtered or unexported fields
}
Middleware wraps and instruments http handlers.
func NewMiddleware ¶ added in v0.2.0
func NewMiddleware(options ...Option) *Middleware
NewMiddleware returns new Middleware with the given options.
func (*Middleware) Collector ¶ added in v0.2.0
func (mw *Middleware) Collector() prometheus.Collector
Collector returns a prometheus collector for the metrics.
func (*Middleware) Handler ¶ added in v0.2.0
Handler returns an instrumented handler with the given name.
func (*Middleware) HandlerFunc ¶ added in v0.2.0
func (mw *Middleware) HandlerFunc(name string, handler http.HandlerFunc) http.Handler
HandlerFunc returns an instrumented handler with the given name.
type Option ¶ added in v0.2.0
type Option interface {
// contains filtered or unexported methods
}
A Option changes the default behavior.
func WithCode ¶
func WithCode() Option
WithCode returns a mux option that adds a status code label to metrics.
func WithConstLabels ¶
func WithConstLabels(labels prometheus.Labels) Option
WithConstLabels returns a mux option that adds constant labels to all metrics. Metrics with the same fully-qualified name must have the same label names in their ConstLabels.
func WithMethod ¶
func WithMethod() Option
WithMethod returns a mux option that adds a method label to metrics.
func WithNamespace ¶
WithNamespace returns a mux option that adds a namespace to all metrics.
type ServeMux ¶
type ServeMux struct { Middleware // contains filtered or unexported fields }
ServeMux is an HTTP request multiplexer that wraps handlers with prometheus instrumentation middleware.
func NewServeMux ¶
NewServeMux returns a new mux with the given options.
func (*ServeMux) Handle ¶
Handle registers the handler for the given pattern. It panics if a handler already exists for pattern.
func (*ServeMux) HandleFunc ¶
func (mux *ServeMux) HandleFunc(pattern string, handler http.HandlerFunc)
HandleFunc registers the handler function for the given pattern. It panics if a handler already exists for pattern.