diff options
author | Romain <romdum@users.noreply.github.com> | 2021-08-07 11:43:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-07 12:43:50 +0300 |
commit | 14762abf0bebc57d355cf763c248cca4cbb60043 (patch) | |
tree | 8b8c53fc6ff5615fc7e4b476c121bed5b4068496 /modules/metrics/collector.go | |
parent | 620c5690ea509f54af24d983060f0897c9ada09b (diff) | |
download | gitea-14762abf0bebc57d355cf763c248cca4cbb60043.tar.gz gitea-14762abf0bebc57d355cf763c248cca4cbb60043.zip |
Separate open and closed issue in metrics (#16637)
* Get the issue counts in one query
Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'modules/metrics/collector.go')
-rwxr-xr-x[-rw-r--r--] | modules/metrics/collector.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/modules/metrics/collector.go b/modules/metrics/collector.go index 6f6cf7cb64..f906b58f7d 100644..100755 --- a/modules/metrics/collector.go +++ b/modules/metrics/collector.go @@ -22,6 +22,8 @@ type Collector struct { Follows *prometheus.Desc HookTasks *prometheus.Desc Issues *prometheus.Desc + IssuesOpen *prometheus.Desc + IssuesClosed *prometheus.Desc Labels *prometheus.Desc LoginSources *prometheus.Desc Milestones *prometheus.Desc @@ -77,6 +79,16 @@ func NewCollector() Collector { "Number of Issues", nil, nil, ), + IssuesOpen: prometheus.NewDesc( + namespace+"issues_open", + "Number of open Issues", + nil, nil, + ), + IssuesClosed: prometheus.NewDesc( + namespace+"issues_closed", + "Number of closed Issues", + nil, nil, + ), Labels: prometheus.NewDesc( namespace+"labels", "Number of Labels", @@ -165,6 +177,8 @@ func (c Collector) Describe(ch chan<- *prometheus.Desc) { ch <- c.Follows ch <- c.HookTasks ch <- c.Issues + ch <- c.IssuesOpen + ch <- c.IssuesClosed ch <- c.Labels ch <- c.LoginSources ch <- c.Milestones @@ -222,6 +236,16 @@ func (c Collector) Collect(ch chan<- prometheus.Metric) { float64(stats.Counter.Issue), ) ch <- prometheus.MustNewConstMetric( + c.IssuesClosed, + prometheus.GaugeValue, + float64(stats.Counter.IssueClosed), + ) + ch <- prometheus.MustNewConstMetric( + c.IssuesOpen, + prometheus.GaugeValue, + float64(stats.Counter.IssueOpen), + ) + ch <- prometheus.MustNewConstMetric( c.Labels, prometheus.GaugeValue, float64(stats.Counter.Label), |