mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08: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:
		@@ -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,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user