Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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.