Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Add git ready metric
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel AguadoAraujo <Daniel.AguadoAraujo@gfk.com>
  • Loading branch information
drazul authored and Kingdon Barrett committed Mar 11, 2021
1 parent d6aeb97 commit 75f214b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
20 changes: 20 additions & 0 deletions pkg/git/metrics.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package git

import (
"github.com/go-kit/kit/metrics/prometheus"
stdprometheus "github.com/prometheus/client_golang/prometheus"
)

const (
MetricRepoReady = 1
MetricRepoUnready = 0
)

var (
metricGitReady = prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
Namespace: "flux",
Subsystem: "git",
Name: "ready",
Help: "Status of the git repository.",
}, []string{})
)
2 changes: 2 additions & 0 deletions pkg/git/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,15 @@ func (r *Repo) Status() (GitRepoStatus, error) {
}

func (r *Repo) setUnready(s GitRepoStatus, err error) {
metricGitReady.Set(MetricRepoUnready)
r.mu.Lock()
r.status = s
r.err = err
r.mu.Unlock()
}

func (r *Repo) setReady() {
metricGitReady.Set(MetricRepoReady)
r.mu.Lock()
r.status = RepoReady
r.err = nil
Expand Down

0 comments on commit 75f214b

Please sign in to comment.