Skip to content

Commit

Permalink
move stats setting to newAutographer
Browse files Browse the repository at this point in the history
  • Loading branch information
jmhodges committed Jul 30, 2024
1 parent c91a7d3 commit b2f580a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
3 changes: 2 additions & 1 deletion stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit b2f580a

Please sign in to comment.