Don't double-register the hook metric

This commit is contained in:
Tim Hockin 2022-01-22 14:24:03 -08:00
parent d8bd262b87
commit 2a611a72c0
1 changed files with 4 additions and 1 deletions

View File

@ -34,6 +34,10 @@ var (
}, []string{"name", "status"}) }, []string{"name", "status"})
) )
func init() {
prometheus.MustRegister(hookRunCount)
}
// Describes what a Hook needs to implement, run by HookRunner // Describes what a Hook needs to implement, run by HookRunner
type Hook interface { type Hook interface {
// Describes hook // 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 // Run waits for trigger events from the channel, and run hook when triggered
func (r *HookRunner) Run(ctx context.Context) { func (r *HookRunner) Run(ctx context.Context) {
var lastHash string var lastHash string
prometheus.MustRegister(hookRunCount)
// Wait for trigger from hookData.Send // Wait for trigger from hookData.Send
for range r.data.events() { for range r.data.events() {