More prometheus metrics

This commit is contained in:
Jonathan Leibiusky @xetorthio
2017-06-14 20:59:50 -03:00
parent 8f247794bb
commit 6c8c21618b
6 changed files with 72 additions and 1 deletions

View File

@@ -21,8 +21,18 @@ var (
Name: "instances",
Help: "Instances",
})
latencyHistogramVec = prometheus.NewHistogramVec(prometheus.HistogramOpts{
Name: "pwd_action_duration_ms",
Help: "How long it took to process a specific action, in a specific host",
Buckets: []float64{300, 1200, 5000},
}, []string{"action"})
)
func observeAction(action string, start time.Time) {
latencyHistogramVec.WithLabelValues(action).Observe(float64(time.Since(start).Nanoseconds()) / 1000000)
}
var sessions map[string]*Session
var sessionsMutex sync.Mutex
@@ -30,6 +40,7 @@ func init() {
prometheus.MustRegister(sessionsGauge)
prometheus.MustRegister(clientsGauge)
prometheus.MustRegister(instancesGauge)
prometheus.MustRegister(latencyHistogramVec)
sessions = make(map[string]*Session)
}