mirror of
https://github.com/go-gitea/gitea.git
synced 2025-07-18 13:02:54 +02:00
add cron inflight metric
This commit is contained in:
parent
96246b93aa
commit
25eee166c4
@ -19,9 +19,17 @@ import (
|
||||
"code.gitea.io/gitea/modules/process"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"code.gitea.io/gitea/modules/translation"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||
)
|
||||
|
||||
var (
|
||||
cronInflight = promauto.NewGauge(prometheus.GaugeOpts{
|
||||
Namespace: "gitea",
|
||||
Subsystem: "cron",
|
||||
Name: "active_tasks",
|
||||
Help: "Number of running cron tasks",
|
||||
})
|
||||
lock = sync.Mutex{}
|
||||
started = false
|
||||
tasks = []*Task{}
|
||||
@ -86,6 +94,8 @@ func (t *Task) RunWithUser(doer *user_model.User, config Config) {
|
||||
taskStatusTable.Stop(t.Name)
|
||||
}()
|
||||
graceful.GetManager().RunWithShutdownContext(func(baseCtx context.Context) {
|
||||
cronInflight.Inc()
|
||||
defer cronInflight.Dec()
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
// Recover a panic within the execution of the task.
|
||||
|
Loading…
x
Reference in New Issue
Block a user