Skip to content

Commit 082846f

Browse files
authored
Merge pull request #81 from bottlepay/empty_keycount
Prevent sending key count when 0.
2 parents a1fa10f + 45dec43 commit 082846f

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

collectors/wallet_collector.go

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -198,17 +198,21 @@ func (u *WalletCollector) Collect(ch chan<- prometheus.Metric) {
198198
path := account.GetDerivationPath()
199199

200200
// internal key count.
201-
ch <- prometheus.MustNewConstMetric(
202-
u.keyCountDesc, prometheus.CounterValue,
203-
float64(account.InternalKeyCount),
204-
name, addrType, path, "internal",
205-
)
201+
if account.InternalKeyCount > 0 {
202+
ch <- prometheus.MustNewConstMetric(
203+
u.keyCountDesc, prometheus.CounterValue,
204+
float64(account.InternalKeyCount),
205+
name, addrType, path, "internal",
206+
)
207+
}
206208

207209
// external key count.
208-
ch <- prometheus.MustNewConstMetric(
209-
u.keyCountDesc, prometheus.CounterValue,
210-
float64(account.ExternalKeyCount),
211-
name, addrType, path, "external",
212-
)
210+
if account.ExternalKeyCount > 0 {
211+
ch <- prometheus.MustNewConstMetric(
212+
u.keyCountDesc, prometheus.CounterValue,
213+
float64(account.ExternalKeyCount),
214+
name, addrType, path, "external",
215+
)
216+
}
213217
}
214218
}

0 commit comments

Comments
 (0)