Documentation ¶
Index ¶
- Constants
- Variables
- func Prom(h Handler) http.Handler
- func PromFunc(h HandlerFunc) http.HandlerFunc
- func Track(h Handle, name string) httprouter.Handle
- func TrackDependency(dep, req, status string, v float64)
- func TrackFunc(name, depType string, v interface{}, f Func) (interface{}, error)
- type Func
- type Handle
- type Handler
- type HandlerFunc
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 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 ¶
This is to track any dependency of an API. Eg. Third party http request or Database/Redis call
Types ¶
type Handle ¶
type Handle func(http.ResponseWriter, *http.Request, httprouter.Params) int
type Handler ¶
Handler interface is similar to HTTP handler, but expects ServerHTTP to return the request name and status code of the HTTP response
type HandlerFunc ¶
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).
Click to show internal directories.
Click to hide internal directories.