instrument

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2016 License: Apache-2.0 Imports: 5 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(ctx context.Context, method string, metric *prometheus.HistogramVec, f func(context.Context) 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". It will also emit an OpenTracing span if you have a global tracer configured.

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

func TimeRequestHistogramStatus

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

TimeRequestHistogramStatus runs 'f' and records how long it took in the given Prometheus histogram metric. It will also emit an OpenTracing span if you have a global tracer configured.

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