mirror of
https://github.com/go-gitea/gitea.git
synced 2025-07-19 19:18:43 +02:00
add system notice counter
This commit is contained in:
parent
c4a81c56f0
commit
9d7283ae3c
@ -8,6 +8,7 @@ import (
|
|||||||
|
|
||||||
activities_model "code.gitea.io/gitea/models/activities"
|
activities_model "code.gitea.io/gitea/models/activities"
|
||||||
"code.gitea.io/gitea/models/db"
|
"code.gitea.io/gitea/models/db"
|
||||||
|
"code.gitea.io/gitea/models/system"
|
||||||
"code.gitea.io/gitea/modules/setting"
|
"code.gitea.io/gitea/modules/setting"
|
||||||
|
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
@ -41,6 +42,7 @@ type Collector struct {
|
|||||||
Releases *prometheus.Desc
|
Releases *prometheus.Desc
|
||||||
Repositories *prometheus.Desc
|
Repositories *prometheus.Desc
|
||||||
Stars *prometheus.Desc
|
Stars *prometheus.Desc
|
||||||
|
SystemNotices *prometheus.Desc
|
||||||
Teams *prometheus.Desc
|
Teams *prometheus.Desc
|
||||||
UpdateTasks *prometheus.Desc
|
UpdateTasks *prometheus.Desc
|
||||||
Users *prometheus.Desc
|
Users *prometheus.Desc
|
||||||
@ -171,6 +173,10 @@ func NewCollector() Collector {
|
|||||||
"Number of Stars",
|
"Number of Stars",
|
||||||
nil, nil,
|
nil, nil,
|
||||||
),
|
),
|
||||||
|
SystemNotices: prometheus.NewDesc(
|
||||||
|
namespace+"system_notices",
|
||||||
|
"Number of system notices",
|
||||||
|
nil, nil),
|
||||||
Teams: prometheus.NewDesc(
|
Teams: prometheus.NewDesc(
|
||||||
namespace+"teams",
|
namespace+"teams",
|
||||||
"Number of Teams",
|
"Number of Teams",
|
||||||
@ -234,6 +240,7 @@ func (c Collector) Describe(ch chan<- *prometheus.Desc) {
|
|||||||
// Collect returns the metrics with values
|
// Collect returns the metrics with values
|
||||||
func (c Collector) Collect(ch chan<- prometheus.Metric) {
|
func (c Collector) Collect(ch chan<- prometheus.Metric) {
|
||||||
stats := activities_model.GetStatistic(db.DefaultContext)
|
stats := activities_model.GetStatistic(db.DefaultContext)
|
||||||
|
noticeCount := system.CountNotices(db.DefaultContext)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.Accesses,
|
c.Accesses,
|
||||||
@ -366,6 +373,11 @@ func (c Collector) Collect(ch chan<- prometheus.Metric) {
|
|||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
float64(stats.Counter.Star),
|
float64(stats.Counter.Star),
|
||||||
)
|
)
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.SystemNotices,
|
||||||
|
prometheus.GaugeValue,
|
||||||
|
float64(noticeCount),
|
||||||
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.Teams,
|
c.Teams,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user