Delete unused instrumentation code

This commit is contained in:
Jonathan Lange
2016-07-26 12:27:50 +01:00
parent 78199aa25f
commit cd716d3510

View File

@@ -14,32 +14,6 @@ func ErrorCode(err error) string {
return "500"
}
// TimeRequest runs 'f' and records how long it took in the given Prometheus
// 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 TimeRequest(method string, metric *prometheus.SummaryVec, f func() error) error {
return TimeRequestStatus(method, metric, ErrorCode, f)
}
// TimeRequestStatus runs 'f' and records how long it took in the given
// Prometheus metric.
//
// toStatusCode is a function that translates errors returned by 'f' into
// HTTP-like status codes.
func TimeRequestStatus(method string, metric *prometheus.SummaryVec, toStatusCode func(error) string, f func() error) error {
if toStatusCode == nil {
toStatusCode = ErrorCode
}
startTime := time.Now()
err := f()
duration := time.Now().Sub(startTime)
metric.WithLabelValues(method, toStatusCode(err)).Observe(duration.Seconds())
return err
}
// 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".