Skip to content

Commit

Permalink
Merge pull request #81 from bottlepay/empty_keycount
Browse files Browse the repository at this point in the history
Prevent sending key count when 0.
  • Loading branch information
guggero authored Apr 22, 2022
2 parents a1fa10f + 45dec43 commit 082846f
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions collectors/wallet_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,17 +198,21 @@ func (u *WalletCollector) Collect(ch chan<- prometheus.Metric) {
path := account.GetDerivationPath()

// internal key count.
ch <- prometheus.MustNewConstMetric(
u.keyCountDesc, prometheus.CounterValue,
float64(account.InternalKeyCount),
name, addrType, path, "internal",
)
if account.InternalKeyCount > 0 {
ch <- prometheus.MustNewConstMetric(
u.keyCountDesc, prometheus.CounterValue,
float64(account.InternalKeyCount),
name, addrType, path, "internal",
)
}

// external key count.
ch <- prometheus.MustNewConstMetric(
u.keyCountDesc, prometheus.CounterValue,
float64(account.ExternalKeyCount),
name, addrType, path, "external",
)
if account.ExternalKeyCount > 0 {
ch <- prometheus.MustNewConstMetric(
u.keyCountDesc, prometheus.CounterValue,
float64(account.ExternalKeyCount),
name, addrType, path, "external",
)
}
}
}

0 comments on commit 082846f

Please sign in to comment.