Skip to content

Commit 2d4e987

Browse files
authored
Merge pull request #99 from reynico/htlc-disable-metrics-toggle
Add a toggle to disable the HTLC monitor metrics
2 parents 10b9b44 + a03710f commit 2d4e987

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed

collectors/prometheus.go

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ type MonitoringConfig struct {
6767

6868
// DisableGraph disables collection of graph metrics
6969
DisableGraph bool
70+
71+
// DisableHtlc disables collection of HTLCs metrics
72+
DisableHtlc bool
7073
}
7174

7275
func DefaultConfig() *PrometheusConfig {
@@ -91,18 +94,19 @@ func NewPrometheusExporter(cfg *PrometheusConfig, lnd *lndclient.LndServices,
9194

9295
htlcMonitor := newHtlcMonitor(lnd.Router, errChan)
9396

94-
collectors := append(
95-
[]prometheus.Collector{
96-
NewChainCollector(lnd.Client, errChan),
97-
NewChannelsCollector(
98-
lnd.Client, errChan, monitoringCfg,
99-
),
100-
NewWalletCollector(lnd, errChan),
101-
NewPeerCollector(lnd.Client, errChan),
102-
NewInfoCollector(lnd.Client, errChan),
103-
},
104-
htlcMonitor.collectors()...,
105-
)
97+
collectors := []prometheus.Collector{
98+
NewChainCollector(lnd.Client, errChan),
99+
NewChannelsCollector(
100+
lnd.Client, errChan, monitoringCfg,
101+
),
102+
NewWalletCollector(lnd, errChan),
103+
NewPeerCollector(lnd.Client, errChan),
104+
NewInfoCollector(lnd.Client, errChan),
105+
}
106+
107+
if !monitoringCfg.DisableHtlc {
108+
collectors = append(collectors, htlcMonitor.collectors()...)
109+
}
106110

107111
if !monitoringCfg.DisableGraph {
108112
collectors = append(collectors, NewGraphCollector(lnd.Client, errChan))

config.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,11 @@ type config struct {
4949
// PrimaryNode is the pubkey of the primary node in primary-gateway setups.
5050
PrimaryNode string `long:"primarynode" description:"Public key of the primary node in a primary-gateway setup"`
5151

52-
// DisableGraph disables collection of graph metrics
52+
// DisableGraph disables collection of graph metrics.
5353
DisableGraph bool `long:"disablegraph" description:"Do not collect graph metrics"`
54+
55+
// DisableHtlc disables the collection of HTLCs metrics.
56+
DisableHtlc bool `long:"disablehtlc" description:"Do not collect HTLCs metrics"`
5457
}
5558

5659
var defaultConfig = config{

lndmon.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ func start() error {
5959

6060
monitoringCfg := collectors.MonitoringConfig{
6161
DisableGraph: cfg.DisableGraph,
62+
DisableHtlc: cfg.DisableHtlc,
6263
}
6364
if cfg.PrimaryNode != "" {
6465
primaryNode, err := route.NewVertexFromStr(cfg.PrimaryNode)

0 commit comments

Comments
 (0)