httpprom

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2023 License: MIT Imports: 5 Imported by: 2

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

func (mw *Middleware) Handler(name string, handler http.Handler) http.Handler

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

func WithNamespace(namespace string) Option

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

func NewServeMux(options ...Option) *ServeMux

NewServeMux returns a new mux with the given options.

func (*ServeMux) Handle

func (mux *ServeMux) Handle(pattern string, handler http.Handler)

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.

func (*ServeMux) ServeHTTP

func (mux *ServeMux) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP dispatches the request to the handler whose pattern most closely matches the request URL.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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