mirror of
https://github.com/zrepl/zrepl.git
synced 2025-03-30 18:27:21 +02:00
Revert "add metric zrepl_daemon_job_up
"
This reverts commit 43ef8f5bf0
.
This commit is contained in:
parent
160e702043
commit
90b35da295
@ -69,7 +69,7 @@ func Run(ctx context.Context, conf *config.Config) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
jobs := newJobs(prometheus.DefaultRegisterer)
|
jobs := newJobs()
|
||||||
|
|
||||||
// start control socket
|
// start control socket
|
||||||
controlJob, err := newControlJob(conf.Global.Control.SockPath, jobs)
|
controlJob, err := newControlJob(conf.Global.Control.SockPath, jobs)
|
||||||
@ -123,8 +123,6 @@ func Run(ctx context.Context, conf *config.Config) error {
|
|||||||
type jobs struct {
|
type jobs struct {
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
|
|
||||||
metrics metrics
|
|
||||||
|
|
||||||
// m protects all fields below it
|
// m protects all fields below it
|
||||||
m sync.RWMutex
|
m sync.RWMutex
|
||||||
wakeups map[string]wakeup.Func // by Job.Name
|
wakeups map[string]wakeup.Func // by Job.Name
|
||||||
@ -132,32 +130,12 @@ type jobs struct {
|
|||||||
jobs map[string]job.Job
|
jobs map[string]job.Job
|
||||||
}
|
}
|
||||||
|
|
||||||
type metrics struct {
|
func newJobs() *jobs {
|
||||||
running *prometheus.GaugeVec
|
return &jobs{
|
||||||
}
|
|
||||||
|
|
||||||
func newJobs(registry prometheus.Registerer) *jobs {
|
|
||||||
jobs := &jobs{
|
|
||||||
metrics: metrics{
|
|
||||||
running: prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
|
||||||
Namespace: "zrepl",
|
|
||||||
Subsystem: "daemon",
|
|
||||||
Name: "job_up",
|
|
||||||
Help: `Each zrepl-level job starts its life with this metric =1.
|
|
||||||
It reamins =1 until the job leaves its Run() function.
|
|
||||||
The purpose of this metric is primarily for Prometheus to be aware of all job names.
|
|
||||||
The value will only transition to 0 during zrepl daemon shutdown or panics.
|
|
||||||
`,
|
|
||||||
}, []string{"zrepl_job", "internal"}),
|
|
||||||
},
|
|
||||||
wakeups: make(map[string]wakeup.Func),
|
wakeups: make(map[string]wakeup.Func),
|
||||||
resets: make(map[string]reset.Func),
|
resets: make(map[string]reset.Func),
|
||||||
jobs: make(map[string]job.Job),
|
jobs: make(map[string]job.Job),
|
||||||
}
|
}
|
||||||
|
|
||||||
registry.MustRegister(jobs.metrics.running)
|
|
||||||
|
|
||||||
return jobs
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *jobs) wait() <-chan struct{} {
|
func (s *jobs) wait() <-chan struct{} {
|
||||||
@ -264,10 +242,7 @@ func (s *jobs) start(ctx context.Context, j job.Job, internal bool) {
|
|||||||
s.resets[jobName] = resetFunc
|
s.resets[jobName] = resetFunc
|
||||||
|
|
||||||
s.wg.Add(1)
|
s.wg.Add(1)
|
||||||
runningJobsGauge := s.metrics.running.WithLabelValues(jobName, fmt.Sprintf("%v", internal))
|
|
||||||
runningJobsGauge.Inc()
|
|
||||||
go func() {
|
go func() {
|
||||||
defer runningJobsGauge.Dec()
|
|
||||||
defer s.wg.Done()
|
defer s.wg.Done()
|
||||||
job.GetLogger(ctx).Info("starting job")
|
job.GetLogger(ctx).Info("starting job")
|
||||||
defer job.GetLogger(ctx).Info("job exited")
|
defer job.GetLogger(ctx).Info("job exited")
|
||||||
|
Loading…
Reference in New Issue
Block a user