Skip to content

Commit

Permalink
fix: init gostats to not flood log (#520)
Browse files Browse the repository at this point in the history
Default gostats store flood messages on stderr except if statd or
if GOSTATS_LOGGING_SINK_DISABLED is set to "true".
This commit init store in a unambiguous way.

Signed-off-by: Guilhem Lettron <[email protected]>
  • Loading branch information
guilhem authored Mar 27, 2024
1 parent 19f2079 commit 78ed1dc
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/service_cmd/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,19 @@ type Runner struct {
}

func NewRunner(s settings.Settings) Runner {

var store gostats.Store
// use statsd
if s.UseStatsd {
store = gostats.NewStore(gostats.NewTCPStatsdSink(gostats.WithStatsdHost(s.StatsdHost), gostats.WithStatsdPort(s.StatsdPort)), false)
} else {
store = gostats.NewStore(gostats.NewNullSink(), false)
}

go store.Start(time.NewTicker(10 * time.Second))

return Runner{
statsManager: stats.NewStatManager(gostats.NewDefaultStore(), s),
statsManager: stats.NewStatManager(store, s),
settings: s,
}
}
Expand Down

0 comments on commit 78ed1dc

Please sign in to comment.