Skip to content

Commit

Permalink
Merge pull request #1722 from weaveworks/summary-execution
Browse files Browse the repository at this point in the history
Delete unused instrumentation code
  • Loading branch information
paulbellamy authored Jul 26, 2016
2 parents 78199aa + cd716d3 commit 0a77d60
Showing 1 changed file with 0 additions and 26 deletions.
26 changes: 0 additions & 26 deletions common/instrument/instrument.go
Original file line number Diff line number Diff line change
Expand Up @@ -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".
Expand Down

0 comments on commit 0a77d60

Please sign in to comment.