From bed85a0642d8d99c6f1eae02b7659da4ea7f03ad Mon Sep 17 00:00:00 2001 From: Aaron Beitch Date: Mon, 30 Dec 2024 16:07:06 -0800 Subject: [PATCH] Add metric for number of active scanner renewers This can be used to identify scanner leaks. --- prometheus.go | 8 ++++++++ scanner.go | 6 +++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/prometheus.go b/prometheus.go index 76ef540e..62eb1ea3 100644 --- a/prometheus.go +++ b/prometheus.go @@ -53,4 +53,12 @@ var ( 4.096, 8.192, 13.192, 18.192, 23.192, 28.192, 33.192, }, }) + + scanRenewers = promauto.NewGauge(prometheus.GaugeOpts{ + Namespace: "gohbase", + Subsystem: "scanner", + Name: "renewer_count", + Help: "Number of active scanner renewers. " + + "A continually increasing value indicates an Scanner leak.", + }) ) diff --git a/scanner.go b/scanner.go index defcbbd4..d1c445bf 100644 --- a/scanner.go +++ b/scanner.go @@ -401,8 +401,12 @@ func (s *scanner) renew(ctx context.Context, startRow []byte) error { } func (s *scanner) renewLoop(ctx context.Context, startRow []byte) { + scanRenewers.Inc() t := time.NewTicker(s.rpc.RenewInterval()) - defer t.Stop() + defer func() { + t.Stop() + scanRenewers.Dec() + }() for { select {