Rename metric variables

This commit is contained in:
Tim Hockin 2023-02-24 08:32:18 -08:00
parent d197740d85
commit 7eaba7605a
1 changed files with 13 additions and 13 deletions

View File

@ -221,22 +221,22 @@ func init() {
// Total pull/error, summary on pull duration // Total pull/error, summary on pull duration
var ( var (
// TODO: have a marker for "which" servergroup // TODO: have a marker for "which" servergroup
syncDuration = prometheus.NewSummaryVec(prometheus.SummaryOpts{ metricSyncDuration = prometheus.NewSummaryVec(prometheus.SummaryOpts{
Name: "git_sync_duration_seconds", Name: "git_sync_duration_seconds",
Help: "Summary of git_sync durations", Help: "Summary of git_sync durations",
}, []string{"status"}) }, []string{"status"})
syncCount = prometheus.NewCounterVec(prometheus.CounterOpts{ metricSyncCount = prometheus.NewCounterVec(prometheus.CounterOpts{
Name: "git_sync_count_total", Name: "git_sync_count_total",
Help: "How many git syncs completed, partitioned by state (success, error, noop)", Help: "How many git syncs completed, partitioned by state (success, error, noop)",
}, []string{"status"}) }, []string{"status"})
fetchCount = prometheus.NewCounter(prometheus.CounterOpts{ metricFetchCount = prometheus.NewCounter(prometheus.CounterOpts{
Name: "git_fetch_count_total", Name: "git_fetch_count_total",
Help: "How many git fetches were run", Help: "How many git fetches were run",
}) })
askpassCount = prometheus.NewCounterVec(prometheus.CounterOpts{ metricAskpassCount = prometheus.NewCounterVec(prometheus.CounterOpts{
Name: "git_sync_askpass_calls", Name: "git_sync_askpass_calls",
Help: "How many git askpass calls completed, partitioned by state (success, error)", Help: "How many git askpass calls completed, partitioned by state (success, error)",
}, []string{"status"}) }, []string{"status"})
@ -268,10 +268,10 @@ const (
const defaultDirMode = os.FileMode(0775) // subject to umask const defaultDirMode = os.FileMode(0775) // subject to umask
func init() { func init() {
prometheus.MustRegister(syncDuration) prometheus.MustRegister(metricSyncDuration)
prometheus.MustRegister(syncCount) prometheus.MustRegister(metricSyncCount)
prometheus.MustRegister(fetchCount) prometheus.MustRegister(metricFetchCount)
prometheus.MustRegister(askpassCount) prometheus.MustRegister(metricAskpassCount)
} }
func envString(def string, key string, alts ...string) string { func envString(def string, key string, alts ...string) string {
@ -948,10 +948,10 @@ func main() {
// When using an auth URL, the credentials can be dynamic, it needs to be // When using an auth URL, the credentials can be dynamic, it needs to be
// re-fetched each time. // re-fetched each time.
if err := git.CallAskPassURL(ctx); err != nil { if err := git.CallAskPassURL(ctx); err != nil {
askpassCount.WithLabelValues(metricKeyError).Inc() metricAskpassCount.WithLabelValues(metricKeyError).Inc()
return err return err
} }
askpassCount.WithLabelValues(metricKeySuccess).Inc() metricAskpassCount.WithLabelValues(metricKeySuccess).Inc()
} }
return nil return nil
} }
@ -1145,8 +1145,8 @@ func logSafeEnv(env []string) []string {
} }
func updateSyncMetrics(key string, start time.Time) { func updateSyncMetrics(key string, start time.Time) {
syncDuration.WithLabelValues(key).Observe(time.Since(start).Seconds()) metricSyncDuration.WithLabelValues(key).Observe(time.Since(start).Seconds())
syncCount.WithLabelValues(key).Inc() metricSyncCount.WithLabelValues(key).Inc()
} }
// repoReady indicates that the repo has been synced. // repoReady indicates that the repo has been synced.
@ -1745,7 +1745,7 @@ func (git *repoSync) SyncRepo(ctx context.Context, refreshCreds func(context.Con
if err := git.fetch(ctx, remoteHash); err != nil { if err := git.fetch(ctx, remoteHash); err != nil {
return false, "", err return false, "", err
} }
fetchCount.Inc() metricFetchCount.Inc()
// Reset the repo (note: not the worktree - that happens later) to the new // Reset the repo (note: not the worktree - that happens later) to the new
// ref. This makes subsequent fetches much less expensive. It uses --soft // ref. This makes subsequent fetches much less expensive. It uses --soft