Browse Source

storage: apply same naming in metrics.go

This is PR following up with Xiang's https://github.com/coreos/etcd/pull/3795,
and to make the naming consistent with its interface change.
Gyu-Ho Lee 10 years ago
parent
commit
bdc280c4a7
2 changed files with 15 additions and 15 deletions
  1. 8 8
      storage/metrics.go
  2. 7 7
      storage/watchable_store.go

+ 8 - 8
storage/metrics.go

@@ -59,20 +59,20 @@ var (
 			Help:      "Total number of keys.",
 			Help:      "Total number of keys.",
 		})
 		})
 
 
-	watchersGauge = prometheus.NewGauge(
+	watchingGauge = prometheus.NewGauge(
 		prometheus.GaugeOpts{
 		prometheus.GaugeOpts{
 			Namespace: "etcd",
 			Namespace: "etcd",
 			Subsystem: "storage",
 			Subsystem: "storage",
-			Name:      "watchers_total",
-			Help:      "Total number of watchers.",
+			Name:      "watching_total",
+			Help:      "Total number of watchings.",
 		})
 		})
 
 
-	slowWatchersGauge = prometheus.NewGauge(
+	slowWatchingGauge = prometheus.NewGauge(
 		prometheus.GaugeOpts{
 		prometheus.GaugeOpts{
 			Namespace: "etcd",
 			Namespace: "etcd",
 			Subsystem: "storage",
 			Subsystem: "storage",
-			Name:      "slow_watchers_total",
-			Help:      "Total number of unsynced slow watchers.",
+			Name:      "slow_watching_total",
+			Help:      "Total number of unsynced slow watchings.",
 		})
 		})
 
 
 	totalEventsCounter = prometheus.NewCounter(
 	totalEventsCounter = prometheus.NewCounter(
@@ -135,9 +135,9 @@ func init() {
 	prometheus.MustRegister(deleteCounter)
 	prometheus.MustRegister(deleteCounter)
 	prometheus.MustRegister(txnCounter)
 	prometheus.MustRegister(txnCounter)
 	prometheus.MustRegister(keysGauge)
 	prometheus.MustRegister(keysGauge)
-	prometheus.MustRegister(watchersGauge)
+	prometheus.MustRegister(watchingGauge)
 	prometheus.MustRegister(totalEventsCounter)
 	prometheus.MustRegister(totalEventsCounter)
-	prometheus.MustRegister(slowWatchersGauge)
+	prometheus.MustRegister(slowWatchingGauge)
 	prometheus.MustRegister(pendingEventsGauge)
 	prometheus.MustRegister(pendingEventsGauge)
 	prometheus.MustRegister(indexCompactionPauseDurations)
 	prometheus.MustRegister(indexCompactionPauseDurations)
 	prometheus.MustRegister(dbCompactionPauseDurations)
 	prometheus.MustRegister(dbCompactionPauseDurations)

+ 7 - 7
storage/watchable_store.go

@@ -186,10 +186,10 @@ func (s *watchableStore) watch(key []byte, prefix bool, startRev int64, ch chan<
 	if startRev == 0 {
 	if startRev == 0 {
 		s.synced[k] = append(s.synced[k], wa)
 		s.synced[k] = append(s.synced[k], wa)
 	} else {
 	} else {
-		slowWatchersGauge.Inc()
+		slowWatchingGauge.Inc()
 		s.unsynced[wa] = struct{}{}
 		s.unsynced[wa] = struct{}{}
 	}
 	}
-	watchersGauge.Inc()
+	watchingGauge.Inc()
 
 
 	cancel := CancelFunc(func() {
 	cancel := CancelFunc(func() {
 		s.mu.Lock()
 		s.mu.Lock()
@@ -197,15 +197,15 @@ func (s *watchableStore) watch(key []byte, prefix bool, startRev int64, ch chan<
 		// remove global references of the watching
 		// remove global references of the watching
 		if _, ok := s.unsynced[wa]; ok {
 		if _, ok := s.unsynced[wa]; ok {
 			delete(s.unsynced, wa)
 			delete(s.unsynced, wa)
-			slowWatchersGauge.Dec()
-			watchersGauge.Dec()
+			slowWatchingGauge.Dec()
+			watchingGauge.Dec()
 			return
 			return
 		}
 		}
 
 
 		for i, w := range s.synced[k] {
 		for i, w := range s.synced[k] {
 			if w == wa {
 			if w == wa {
 				s.synced[k] = append(s.synced[k][:i], s.synced[k][i+1:]...)
 				s.synced[k] = append(s.synced[k][:i], s.synced[k][i+1:]...)
-				watchersGauge.Dec()
+				watchingGauge.Dec()
 			}
 			}
 		}
 		}
 		// If we cannot find it, it should have finished watch.
 		// If we cannot find it, it should have finished watch.
@@ -267,7 +267,7 @@ func (s *watchableStore) syncWatchings() {
 		// put it back to try it in the next round
 		// put it back to try it in the next round
 		w.cur = nextRev
 		w.cur = nextRev
 	}
 	}
-	slowWatchersGauge.Set(float64(len(s.unsynced)))
+	slowWatchingGauge.Set(float64(len(s.unsynced)))
 }
 }
 
 
 // handle handles the change of the happening event on all watchings.
 // handle handles the change of the happening event on all watchings.
@@ -295,7 +295,7 @@ func (s *watchableStore) notify(rev int64, ev storagepb.Event) {
 			default:
 			default:
 				w.cur = rev
 				w.cur = rev
 				s.unsynced[w] = struct{}{}
 				s.unsynced[w] = struct{}{}
-				slowWatchersGauge.Inc()
+				slowWatchingGauge.Inc()
 			}
 			}
 		}
 		}
 		s.synced[string(ev.Kv.Key[:i])] = nws
 		s.synced[string(ev.Kv.Key[:i])] = nws