From b2f580a4d4df52775ad4fa06d1235b5998afbac5 Mon Sep 17 00:00:00 2001 From: Jeff Hodges Date: Tue, 30 Jul 2024 09:42:44 -0700 Subject: [PATCH] move stats setting to newAutographer --- main.go | 1 + stats.go | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index c06822b70..6e1c2c7ac 100755 --- a/main.go +++ b/main.go @@ -291,6 +291,7 @@ func newAutographer(cachesize int) (a *autographer) { a.authBackend = newInMemoryAuthBackend() a.nonces, err = lru.New(cachesize) a.exit = make(chan interface{}) + a.stats = &statsd.NoOpClient{} if err != nil { log.Fatal(err) } diff --git a/stats.go b/stats.go index 107e3b603..8c5209797 100644 --- a/stats.go +++ b/stats.go @@ -20,7 +20,8 @@ func loadStatsd(conf configuration) (*statsd.Client, error) { func (a *autographer) addStats(conf configuration) (err error) { if conf.Statsd.Addr != "" { - a.stats = &statsd.NoOpClient{} + // a.stats is set to a safe value in newAutographer, so we leave it + // alone and return. log.Infof("Statsd disabled as no statsd address was provided") return nil }