Skip to content

Commit b5727d6

Browse files
author
James
committed
add created_at and release labels
1 parent 4df1d63 commit b5727d6

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

exporter/metrics.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func AddMetrics() map[string]*prometheus.Desc {
3737
APIMetrics["ReleaseDownloads"] = prometheus.NewDesc(
3838
prometheus.BuildFQName("github", "repo", "release_downloads"),
3939
"Download count for a given release",
40-
[]string{"repo", "user", "name"}, nil,
40+
[]string{"repo", "user", "release", "name", "created_at"}, nil,
4141
)
4242
APIMetrics["Limit"] = prometheus.NewDesc(
4343
prometheus.BuildFQName("github", "rate", "limit"),
@@ -71,7 +71,7 @@ func (e *Exporter) processMetrics(data []*Datum, rates *RateLimits, ch chan<- pr
7171

7272
for _, release := range x.Releases {
7373
for _, asset := range release.Assets {
74-
ch <- prometheus.MustNewConstMetric(e.APIMetrics["ReleaseDownloads"], prometheus.GaugeValue, float64(asset.Downloads), x.Name, x.Owner.Login, asset.Name)
74+
ch <- prometheus.MustNewConstMetric(e.APIMetrics["ReleaseDownloads"], prometheus.GaugeValue, float64(asset.Downloads), x.Name, x.Owner.Login, release.Name, asset.Name, asset.CreatedAt)
7575
}
7676
}
7777
}

exporter/structs.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,10 @@ type Release struct {
4646
}
4747

4848
type Asset struct {
49-
Name string `json:"name"`
50-
Size int64 `json:"size"`
51-
Downloads int32 `json:"download_count"`
49+
Name string `json:"name"`
50+
Size int64 `json:"size"`
51+
Downloads int32 `json:"download_count"`
52+
CreatedAt string `json:"created_at"`
5253
}
5354

5455
// RateLimits is used to store rate limit data into a struct

0 commit comments

Comments
 (0)