Merge pull request #3810 from gyuho/storage_metrics_add_watcher_gauge

storage: add metrics to watcher
release-2.3
Xiang Li 2015-11-04 13:09:07 -08:00
commit 319b77b051
2 changed files with 12 additions and 1 deletions

View File

@ -59,6 +59,14 @@ var (
Help: "Total number of keys.", Help: "Total number of keys.",
}) })
watcherGauge = prometheus.NewGauge(
prometheus.GaugeOpts{
Namespace: "etcd",
Subsystem: "storage",
Name: "watcher_total",
Help: "Total number of watchers.",
})
watchingGauge = prometheus.NewGauge( watchingGauge = prometheus.NewGauge(
prometheus.GaugeOpts{ prometheus.GaugeOpts{
Namespace: "etcd", Namespace: "etcd",
@ -135,9 +143,10 @@ func init() {
prometheus.MustRegister(deleteCounter) prometheus.MustRegister(deleteCounter)
prometheus.MustRegister(txnCounter) prometheus.MustRegister(txnCounter)
prometheus.MustRegister(keysGauge) prometheus.MustRegister(keysGauge)
prometheus.MustRegister(watcherGauge)
prometheus.MustRegister(watchingGauge) prometheus.MustRegister(watchingGauge)
prometheus.MustRegister(totalEventsCounter)
prometheus.MustRegister(slowWatchingGauge) prometheus.MustRegister(slowWatchingGauge)
prometheus.MustRegister(totalEventsCounter)
prometheus.MustRegister(pendingEventsGauge) prometheus.MustRegister(pendingEventsGauge)
prometheus.MustRegister(indexCompactionPauseDurations) prometheus.MustRegister(indexCompactionPauseDurations)
prometheus.MustRegister(dbCompactionPauseDurations) prometheus.MustRegister(dbCompactionPauseDurations)

View File

@ -56,6 +56,7 @@ func (ws *watcher) Watch(key []byte, prefix bool, startRev int64) CancelFunc {
} }
// TODO: cancelFunc needs to be removed from the cancels when it is called. // TODO: cancelFunc needs to be removed from the cancels when it is called.
ws.cancels = append(ws.cancels, c) ws.cancels = append(ws.cancels, c)
watcherGauge.Inc()
return c return c
} }
@ -72,4 +73,5 @@ func (ws *watcher) Close() {
} }
ws.closed = true ws.closed = true
close(ws.ch) close(ws.ch)
watcherGauge.Dec()
} }