mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-25 11:22:16 +00:00
Add metrics to get issues by label (#17201)
* Add metrics to get issues by label * Add comment on IssueByLabelCount * Code review - Unify "AS" in SQL (#17201) * Code review - Remove useless join (#17201) * Code review - Disable issue_by_label by default in settings (#17201) * use e * restore empty line * update docs Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: techknowlogick <matti@mdranta.net> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
This commit is contained in:
parent
89ddbe9699
commit
fc5ee1edf9
5 changed files with 44 additions and 5 deletions
|
@ -24,6 +24,7 @@ type Collector struct {
|
|||
Issues *prometheus.Desc
|
||||
IssuesOpen *prometheus.Desc
|
||||
IssuesClosed *prometheus.Desc
|
||||
IssuesByLabel *prometheus.Desc
|
||||
Labels *prometheus.Desc
|
||||
LoginSources *prometheus.Desc
|
||||
Milestones *prometheus.Desc
|
||||
|
@ -45,6 +46,7 @@ type Collector struct {
|
|||
|
||||
// NewCollector returns a new Collector with all prometheus.Desc initialized
|
||||
func NewCollector() Collector {
|
||||
|
||||
return Collector{
|
||||
Accesses: prometheus.NewDesc(
|
||||
namespace+"accesses",
|
||||
|
@ -81,6 +83,11 @@ func NewCollector() Collector {
|
|||
"Number of Issues",
|
||||
nil, nil,
|
||||
),
|
||||
IssuesByLabel: prometheus.NewDesc(
|
||||
namespace+"issues_by_label",
|
||||
"Number of Issues",
|
||||
[]string{"label"}, nil,
|
||||
),
|
||||
IssuesOpen: prometheus.NewDesc(
|
||||
namespace+"issues_open",
|
||||
"Number of open Issues",
|
||||
|
@ -177,7 +184,6 @@ func NewCollector() Collector {
|
|||
nil, nil,
|
||||
),
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Describe returns all possible prometheus.Desc
|
||||
|
@ -189,6 +195,7 @@ func (c Collector) Describe(ch chan<- *prometheus.Desc) {
|
|||
ch <- c.Follows
|
||||
ch <- c.HookTasks
|
||||
ch <- c.Issues
|
||||
ch <- c.IssuesByLabel
|
||||
ch <- c.IssuesOpen
|
||||
ch <- c.IssuesClosed
|
||||
ch <- c.Labels
|
||||
|
@ -249,6 +256,14 @@ func (c Collector) Collect(ch chan<- prometheus.Metric) {
|
|||
prometheus.GaugeValue,
|
||||
float64(stats.Counter.Issue),
|
||||
)
|
||||
for _, il := range stats.Counter.IssueByLabel {
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.IssuesByLabel,
|
||||
prometheus.GaugeValue,
|
||||
float64(il.Count),
|
||||
il.Label,
|
||||
)
|
||||
}
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.IssuesClosed,
|
||||
prometheus.GaugeValue,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue