@@ -3,6 +3,7 @@ package exporter
33import "github.com/prometheus/client_golang/prometheus"
44import "strconv"
55
6+
67// AddMetrics - Add's all of the metrics to a map of strings, returns the map.
78func AddMetrics () map [string ]* prometheus.Desc {
89
@@ -33,6 +34,11 @@ func AddMetrics() map[string]*prometheus.Desc {
3334 "Size in KB for given repository" ,
3435 []string {"repo" , "user" , "private" , "fork" , "archived" , "license" , "language" }, nil ,
3536 )
37+ APIMetrics ["ReleaseDownloads" ] = prometheus .NewDesc (
38+ prometheus .BuildFQName ("github" , "repo" , "release_downloads" ),
39+ "Download count for a given release" ,
40+ []string {"repo" , "user" , "release" , "name" , "created_at" }, nil ,
41+ )
3642 APIMetrics ["Limit" ] = prometheus .NewDesc (
3743 prometheus .BuildFQName ("github" , "rate" , "limit" ),
3844 "Number of API queries allowed in a 60 minute window" ,
@@ -63,6 +69,11 @@ func (e *Exporter) processMetrics(data []*Datum, rates *RateLimits, ch chan<- pr
6369 ch <- prometheus .MustNewConstMetric (e .APIMetrics ["Watchers" ], prometheus .GaugeValue , x .Watchers , x .Name , x .Owner .Login , strconv .FormatBool (x .Private ), strconv .FormatBool (x .Fork ), strconv .FormatBool (x .Archived ), x .License .Key , x .Language )
6470 ch <- prometheus .MustNewConstMetric (e .APIMetrics ["Size" ], prometheus .GaugeValue , x .Size , x .Name , x .Owner .Login , strconv .FormatBool (x .Private ), strconv .FormatBool (x .Fork ), strconv .FormatBool (x .Archived ), x .License .Key , x .Language )
6571
72+ for _ , release := range x .Releases {
73+ for _ , asset := range release .Assets {
74+ ch <- prometheus .MustNewConstMetric (e .APIMetrics ["ReleaseDownloads" ], prometheus .GaugeValue , float64 (asset .Downloads ), x .Name , x .Owner .Login , release .Name , asset .Name , asset .CreatedAt )
75+ }
76+ }
6677 }
6778
6879 // Set Rate limit stats
0 commit comments