prom

package
v0.0.0-...-a9b8012 Latest Latest
Warning

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

Go to latest
Published: May 12, 2019 License: MIT Imports: 4 Imported by: 4

Documentation

Index

Constants

View Source
const (
	DependencyHTTP  = "HTTP"
	DependencyRedis = "Redis"
	DependencyDB    = "DB"

	Label5xx = "5xx"
	Label4xx = "4xx"
	Label3xx = "3xx"
	Label2xx = "2xx"
)

Variables

View Source
var (
	StatusSuccess = "Success"
	StatusFailed  = "Failed"
)

Functions

func Prom

func Prom(h Handler) http.Handler

Prom is HTTP middleware to instrument prometheus metrics

func PromFunc

func PromFunc(h HandlerFunc) http.HandlerFunc

Prom Func is HTTP middleware to instrument prometheus metrics

func Track

func Track(h Handle, name string) httprouter.Handle

Track function is a wrapper/closure over httprouter's handler. It will publish the HTTP response time metrics to prometheus's /metrics

func TrackDependency

func TrackDependency(dep, req, status string, v float64)

This is to track any dependency of an API. Eg. Third party http request or Database/Redis call

func TrackFunc

func TrackFunc(name, depType string, v interface{}, f Func) (interface{}, error)

TrackFuck is a wrapper/closure over any dependency functions (Database, third party HTTP calls, Redis etc). It publishes dependency response time metrics to prometheus's /metrics

Types

type Func

type Func func(v interface{}) (interface{}, error)

type Handler

type Handler interface {
	ServeHTTP(w http.ResponseWriter, r *http.Request) (string, int)
}

Handler interface is similar to HTTP handler, but expects ServerHTTP to return the request name and status code of the HTTP response

type HandlerFunc

type HandlerFunc func(http.ResponseWriter, *http.Request) (string, int)

The HandlerFunc type is an adapter to allow the use of ordinary functions as HTTP handlers. If f is a function with the appropriate signature, HandlerFunc(f) is a Handler that calls f.

func (HandlerFunc) ServeHTTP

func (f HandlerFunc) ServeHTTP(w http.ResponseWriter, r *http.Request) (string, int)

ServeHTTP calls f(w, r).

Jump to

Keyboard shortcuts

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