From d8bbd93bf6085102ac44cd6c4866d2f400cf8cd7 Mon Sep 17 00:00:00 2001 From: ziggie Date: Fri, 20 Feb 2026 20:30:20 +0100 Subject: [PATCH] collectors: tolerate DeadlineExceeded in PeerCollector ChainCollector and ChannelsCollector already handle gRPC deadline exceeded errors gracefully by logging and skipping the scrape cycle rather than crashing. PeerCollector was missing this same guard, causing lndmon to exit whenever lnd was temporarily slow to respond to a ListPeers call. --- collectors/peer_collector.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/collectors/peer_collector.go b/collectors/peer_collector.go index 7e9b3a1..457d805 100644 --- a/collectors/peer_collector.go +++ b/collectors/peer_collector.go @@ -89,8 +89,17 @@ func (p *PeerCollector) Describe(ch chan<- *prometheus.Desc) { func (p *PeerCollector) Collect(ch chan<- prometheus.Metric) { listPeersResp, err := p.lnd.ListPeers(context.Background()) if err != nil { - p.errChan <- fmt.Errorf("PeerCollector ListPeers failed with: "+ - "%v", err) + errWithContext := fmt.Errorf("PeerCollector ListPeers failed with: "+ + "%w", err) + Logger.Error(errWithContext) + + // A deadline exceeded is expected if lnd is temporarily slow + // to respond (e.g. due to database load). We just skip this + // scrape cycle and let Prometheus retry on the next interval. + if !IsDeadlineExceeded(err) { + p.errChan <- errWithContext + } + return }