Skip to content

Commit

Permalink
collectors: fix linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
guggero committed Jul 25, 2022
1 parent f363224 commit aa8f3de
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 19 deletions.
28 changes: 14 additions & 14 deletions collectors/channels_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/prometheus/client_golang/prometheus"
)

// ChannelsCollector is a collector that keeps track of channel infromation.
// ChannelsCollector is a collector that keeps track of channel information.
type ChannelsCollector struct {
channelBalanceDesc *prometheus.Desc
pendingChannelBalanceDesc *prometheus.Desc
Expand Down Expand Up @@ -279,7 +279,7 @@ func (c *ChannelsCollector) Collect(ch chan<- prometheus.Metric) {
initiator := initiatorLabel(channel)
peer := channel.PubKeyBytes.String()

chanIdStr := strconv.Itoa(int(channel.ChannelID))
chanIDStr := strconv.Itoa(int(channel.ChannelID))

primaryChannel := c.primaryNode != nil &&
channel.PubKeyBytes == *c.primaryNode
Expand All @@ -292,57 +292,57 @@ func (c *ChannelsCollector) Collect(ch chan<- prometheus.Metric) {

ch <- prometheus.MustNewConstMetric(
c.incomingChanSatDesc, prometheus.GaugeValue,
float64(channel.RemoteBalance), chanIdStr, status,
float64(channel.RemoteBalance), chanIDStr, status,
initiator, peer,
)
ch <- prometheus.MustNewConstMetric(
c.outgoingChanSatDesc, prometheus.GaugeValue,
float64(channel.LocalBalance), chanIdStr, status,
float64(channel.LocalBalance), chanIDStr, status,
initiator, peer,
)
ch <- prometheus.MustNewConstMetric(
c.numPendingHTLCsDesc, prometheus.GaugeValue,
float64(channel.NumPendingHtlcs), chanIdStr, status,
float64(channel.NumPendingHtlcs), chanIDStr, status,
initiator, peer,
)
ch <- prometheus.MustNewConstMetric(
c.satsSentDesc, prometheus.GaugeValue,
float64(channel.TotalSent), chanIdStr, status,
float64(channel.TotalSent), chanIDStr, status,
initiator, peer,
)
ch <- prometheus.MustNewConstMetric(
c.satsRecvDesc, prometheus.GaugeValue,
float64(channel.TotalReceived), chanIdStr, status,
float64(channel.TotalReceived), chanIDStr, status,
initiator, peer,
)
ch <- prometheus.MustNewConstMetric(
c.numUpdatesDesc, prometheus.GaugeValue,
float64(channel.NumUpdates), chanIdStr, status,
float64(channel.NumUpdates), chanIDStr, status,
initiator, peer,
)
ch <- prometheus.MustNewConstMetric(
c.csvDelayDesc, prometheus.GaugeValue,
float64(channel.LocalConstraints.CsvDelay), chanIdStr,
float64(channel.LocalConstraints.CsvDelay), chanIDStr,
status, initiator, peer,
)
ch <- prometheus.MustNewConstMetric(
c.unsettledBalanceDesc, prometheus.GaugeValue,
float64(channel.UnsettledBalance), chanIdStr, status,
float64(channel.UnsettledBalance), chanIDStr, status,
initiator, peer,
)
ch <- prometheus.MustNewConstMetric(
c.feePerKwDesc, prometheus.GaugeValue,
float64(channel.FeePerKw), chanIdStr, status, initiator,
float64(channel.FeePerKw), chanIDStr, status, initiator,
peer,
)
ch <- prometheus.MustNewConstMetric(
c.commitWeightDesc, prometheus.GaugeValue,
float64(channel.CommitWeight), chanIdStr, status,
float64(channel.CommitWeight), chanIDStr, status,
initiator, peer,
)
ch <- prometheus.MustNewConstMetric(
c.commitFeeDesc, prometheus.GaugeValue,
float64(channel.CommitFee), chanIdStr, status,
float64(channel.CommitFee), chanIDStr, status,
initiator, peer,
)

Expand All @@ -351,7 +351,7 @@ func (c *ChannelsCollector) Collect(ch chan<- prometheus.Metric) {
ch <- prometheus.MustNewConstMetric(
c.channelUptimeDesc, prometheus.GaugeValue,
float64(channel.Uptime)/float64(channel.LifeTime),
chanIdStr, status, initiator, peer,
chanIDStr, status, initiator, peer,
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion collectors/graph_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ func (g *GraphCollector) Collect(ch chan<- prometheus.Metric) {

ch <- prometheus.MustNewConstMetric(
g.avgOutDegreeDesc, prometheus.GaugeValue,
float64(networkInfo.AvgOutDegree),
networkInfo.AvgOutDegree,
)
ch <- prometheus.MustNewConstMetric(
g.maxOutDegreeDesc, prometheus.GaugeValue,
Expand Down
4 changes: 2 additions & 2 deletions collectors/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ var (
// initLogRotator initializes the logging rotator to write logs to logFile and
// create roll files in the same directory. It must be called before the
// package-global log rotator variables are used.
func initLogRotator(logFile string, MaxLogFileSize int, MaxLogFiles int) error {
func initLogRotator(logFile string, maxLogFileSize int, maxLogFiles int) error {
logDir, _ := filepath.Split(logFile)
err := os.MkdirAll(logDir, 0700)
if err != nil {
return fmt.Errorf("failed to create log directory: %v", err)
}

r, err := rotator.New(
logFile, int64(MaxLogFileSize*1024), false, MaxLogFiles,
logFile, int64(maxLogFileSize*1024), false, maxLogFiles,
)
if err != nil {
return fmt.Errorf("failed to create file rotator: %v", err)
Expand Down
1 change: 0 additions & 1 deletion collectors/stats_compiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ func newStatsCompiler(numSamples uint32) statsCompiler {

// Observe logs a new value in the set of existing samples.
func (s *statsCompiler) Observe(value float64) {

// First, we'll update our min/max, if needed.
if value > s.max {
s.max = value
Expand Down
2 changes: 1 addition & 1 deletion collectors/wallet_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func (u *WalletCollector) Collect(ch chan<- prometheus.Metric) {
)

ch <- prometheus.MustNewConstMetric(
u.avgUtxoSizeDesc, prometheus.GaugeValue, float64(avg),
u.avgUtxoSizeDesc, prometheus.GaugeValue, avg,
)

// Next, we'll query the wallet to determine our confirmed and unconf
Expand Down

0 comments on commit aa8f3de

Please sign in to comment.