From 2a611a72c0422216c67466fc54f649ce5d66fbea Mon Sep 17 00:00:00 2001 From: Tim Hockin Date: Sat, 22 Jan 2022 14:24:03 -0800 Subject: [PATCH] Don't double-register the hook metric --- pkg/hook/hook.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/hook/hook.go b/pkg/hook/hook.go index 13f92e3..afc2f21 100644 --- a/pkg/hook/hook.go +++ b/pkg/hook/hook.go @@ -34,6 +34,10 @@ var ( }, []string{"name", "status"}) ) +func init() { + prometheus.MustRegister(hookRunCount) +} + // Describes what a Hook needs to implement, run by HookRunner type Hook interface { // Describes hook @@ -113,7 +117,6 @@ func (r *HookRunner) Send(hash string) { // Run waits for trigger events from the channel, and run hook when triggered func (r *HookRunner) Run(ctx context.Context) { var lastHash string - prometheus.MustRegister(hookRunCount) // Wait for trigger from hookData.Send for range r.data.events() {