Skip to content

Commit

Permalink
Add metric for number of active scanner renewers
Browse files Browse the repository at this point in the history
This can be used to identify scanner leaks.
  • Loading branch information
aaronbee committed Dec 31, 2024
1 parent 7492f7e commit bed85a0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
8 changes: 8 additions & 0 deletions prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
})
)
6 changes: 5 additions & 1 deletion scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit bed85a0

Please sign in to comment.