Skip to content

Commit 9d7283a

Browse files
committed
add system notice counter
1 parent c4a81c5 commit 9d7283a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

modules/metrics/collector.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
activities_model "code.gitea.io/gitea/models/activities"
1010
"code.gitea.io/gitea/models/db"
11+
"code.gitea.io/gitea/models/system"
1112
"code.gitea.io/gitea/modules/setting"
1213

1314
"github.com/prometheus/client_golang/prometheus"
@@ -41,6 +42,7 @@ type Collector struct {
4142
Releases *prometheus.Desc
4243
Repositories *prometheus.Desc
4344
Stars *prometheus.Desc
45+
SystemNotices *prometheus.Desc
4446
Teams *prometheus.Desc
4547
UpdateTasks *prometheus.Desc
4648
Users *prometheus.Desc
@@ -171,6 +173,10 @@ func NewCollector() Collector {
171173
"Number of Stars",
172174
nil, nil,
173175
),
176+
SystemNotices: prometheus.NewDesc(
177+
namespace+"system_notices",
178+
"Number of system notices",
179+
nil, nil),
174180
Teams: prometheus.NewDesc(
175181
namespace+"teams",
176182
"Number of Teams",
@@ -234,6 +240,7 @@ func (c Collector) Describe(ch chan<- *prometheus.Desc) {
234240
// Collect returns the metrics with values
235241
func (c Collector) Collect(ch chan<- prometheus.Metric) {
236242
stats := activities_model.GetStatistic(db.DefaultContext)
243+
noticeCount := system.CountNotices(db.DefaultContext)
237244

238245
ch <- prometheus.MustNewConstMetric(
239246
c.Accesses,
@@ -366,6 +373,11 @@ func (c Collector) Collect(ch chan<- prometheus.Metric) {
366373
prometheus.GaugeValue,
367374
float64(stats.Counter.Star),
368375
)
376+
ch <- prometheus.MustNewConstMetric(
377+
c.SystemNotices,
378+
prometheus.GaugeValue,
379+
float64(noticeCount),
380+
)
369381
ch <- prometheus.MustNewConstMetric(
370382
c.Teams,
371383
prometheus.GaugeValue,

0 commit comments

Comments
 (0)