Merge a9a668f9e83459e9c511eed0603b3b16564da950 into c86c93ca2951338115159dcdd20711603044e1f1

This commit is contained in:
Jimmy- 2024-09-26 22:00:05 +01:00 committed by GitHub
commit bdbbf010da
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 0 deletions

View File

@ -313,6 +313,7 @@ func (le *lessor) Grant(id LeaseID, ttl int64) (*Lease, error) {
leaseTotalTTLs.Observe(float64(l.ttl))
leaseGranted.Inc()
leaseActive.Inc()
if le.isPrimary() {
item := &LeaseWithTime{id: l.ID, time: l.expiry}
@ -361,6 +362,7 @@ func (le *lessor) Revoke(id LeaseID) error {
txn.End()
leaseRevoked.Inc()
leaseActive.Dec()
return nil
}
@ -822,6 +824,7 @@ func (le *lessor) initAndRecover() {
}
le.leaseExpiredNotifier.Init()
heap.Init(&le.leaseCheckpointHeap)
leaseActive.Set(float64(len(le.leaseMap)))
le.b.ForceCommit()
}

View File

@ -49,6 +49,13 @@ var (
// 1 second -> 3 months
Buckets: prometheus.ExponentialBuckets(1, 2, 24),
})
leaseActive = prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: "etcd_debugging",
Subsystem: "lease",
Name: "active",
Help: "The current number of active leases.",
})
)
func init() {
@ -56,4 +63,5 @@ func init() {
prometheus.MustRegister(leaseRevoked)
prometheus.MustRegister(leaseRenewed)
prometheus.MustRegister(leaseTotalTTLs)
prometheus.MustRegister(leaseActive)
}