mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-04 18:51:17 +00:00
* Vendor nats-io/nats * Use NATS for shortcut reports. * Review feedback. * Rejig shortcut subscriptions, so they work. * Review feedback
23 lines
445 B
Go
23 lines
445 B
Go
package multitenant
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
)
|
|
|
|
func errorCode(err error) string {
|
|
if err == nil {
|
|
return "200"
|
|
}
|
|
return "500"
|
|
}
|
|
|
|
func timeRequest(method string, metric *prometheus.SummaryVec, f func() error) error {
|
|
startTime := time.Now()
|
|
err := f()
|
|
duration := time.Now().Sub(startTime)
|
|
metric.WithLabelValues(method, errorCode(err)).Observe(float64(duration.Nanoseconds()))
|
|
return err
|
|
}
|