instrument

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2016 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorCode

func ErrorCode(err error) string

ErrorCode converts an error in to an http-style error-code.

func TimeRequestHistogram

func TimeRequestHistogram(method string, metric *prometheus.HistogramVec, f func() error) error

TimeRequestHistogram runs 'f' and records how long it took in the given Prometheus histogram metric. If 'f' returns successfully, record a "200". Otherwise, record "500".

If you want more complicated logic for translating errors into statuses, use 'TimeRequestStatus'.

func TimeRequestHistogramStatus

func TimeRequestHistogramStatus(method string, metric *prometheus.HistogramVec, toStatusCode func(error) string, f func() error) error

TimeRequestHistogramStatus runs 'f' and records how long it took in the given Prometheus histogram metric.

toStatusCode is a function that translates errors returned by 'f' into HTTP-like status codes.

Types

This section is empty.

Jump to

Keyboard shortcuts

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