From cd716d35108803135561c54ef925b635e048e436 Mon Sep 17 00:00:00 2001 From: Jonathan Lange Date: Tue, 26 Jul 2016 12:27:50 +0100 Subject: [PATCH] Delete unused instrumentation code --- common/instrument/instrument.go | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/common/instrument/instrument.go b/common/instrument/instrument.go index 0c6151d219..96b2dfee04 100644 --- a/common/instrument/instrument.go +++ b/common/instrument/instrument.go @@ -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".