Skip to content

Commit

Permalink
refactor: name new metric in help message
Browse files Browse the repository at this point in the history
  • Loading branch information
thde committed Jun 13, 2024
1 parent bf2611f commit 63e2999
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions exporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ const namespace = "rtorrent"
var (
rtorrentInfo = prometheus.NewDesc(prometheus.BuildFQName(namespace, "", "info"), "rtorrent info.", []string{"name", "ip"}, nil)
rtorrentUp = prometheus.NewDesc(prometheus.BuildFQName(namespace, "", "up"), "Was the last scrape of rTorrent successful.", nil, nil)
rtorrentDownloaded = prometheus.NewDesc(prometheus.BuildFQName(namespace, "", "downloaded_bytes"), "Total downloaded bytes, deprecated", nil, nil)
rtorrentDownloadedTotal = prometheus.NewDesc(prometheus.BuildFQName(namespace, "", "downloaded_bytes_total"), "Total downloaded bytes", nil, nil)
rtorrentUploaded = prometheus.NewDesc(prometheus.BuildFQName(namespace, "", "uploaded_bytes"), "Total uploaded bytes, deprecated", nil, nil)
rtorrentUploadedTotal = prometheus.NewDesc(prometheus.BuildFQName(namespace, "", "uploaded_bytes_total"), "Total uploaded bytes", nil, nil)
rtorrentTorrents = prometheus.NewDesc(prometheus.BuildFQName(namespace, "", "torrents_total"), "Torrent count by view.", []string{"view", "label"}, nil)

// Deprected Metrics

Check failure on line 19 in exporter/exporter.go

View workflow job for this annotation

GitHub Actions / lint

Comment should end in a period (godot)
rtorrentDownloadedDeprecated = prometheus.NewDesc(prometheus.BuildFQName(namespace, "", "downloaded_bytes"), "DEPRECATED: use downloaded_bytes_total", nil, nil)
rtorrentUploadedDeprecated = prometheus.NewDesc(prometheus.BuildFQName(namespace, "", "uploaded_bytes"), "DEPRECATED: use uploaded_bytes_total", nil, nil)
)

// Exporter returns a prometheus.Collector that gathers rTorrent metrics.
Expand Down Expand Up @@ -64,15 +66,15 @@ func (e *Exporter) scrape(ch chan<- prometheus.Metric) (up float64) {
return 1

}
ch <- prometheus.MustNewConstMetric(rtorrentDownloaded, prometheus.CounterValue, float64(downloaded))
ch <- prometheus.MustNewConstMetric(rtorrentDownloadedDeprecated, prometheus.CounterValue, float64(downloaded))
ch <- prometheus.MustNewConstMetric(rtorrentDownloadedTotal, prometheus.CounterValue, float64(downloaded))

uploaded, err := e.Client.UpTotal()
if err != nil {
level.Error(e.Logger).Log("msg", "Can't scrape rTorrent", "err", err)
return 1
}
ch <- prometheus.MustNewConstMetric(rtorrentUploaded, prometheus.CounterValue, float64(uploaded))
ch <- prometheus.MustNewConstMetric(rtorrentUploadedDeprecated, prometheus.CounterValue, float64(uploaded))
ch <- prometheus.MustNewConstMetric(rtorrentUploadedTotal, prometheus.CounterValue, float64(uploaded))

for name, view := range map[string]rtorrent.View{
Expand Down

0 comments on commit 63e2999

Please sign in to comment.