Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add logs during StatsD client creation #43

Merged
merged 1 commit into from
May 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions stats/statsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,26 @@ func (s *statsdStats) Start(ctx context.Context, goFactory GoRoutineFactory) (er
// So, that nil pointer error is not received when client is called.
s.state.client.statsd, err = statsd.New(s.state.conn, s.statsdConfig.statsdTagsFormat(), s.statsdConfig.statsdDefaultTags())
if err == nil {
s.logger.Info("StatsD client setup succeeded.")
s.state.clientsLock.Lock()
s.state.connEstablished = true
s.state.clientsLock.Unlock()
}

goFactory.Go(func() {
if err != nil {
s.logger.Info("retrying StatsD client creation in the background...")
s.state.client.statsd, err = s.getNewStatsdClientWithExpoBackoff(ctx, s.state.conn, s.statsdConfig.statsdTagsFormat(), s.statsdConfig.statsdDefaultTags())
if err != nil {
s.config.enabled.Store(false)
s.logger.Errorf("error while creating new statsd client: %v", err)
s.logger.Errorf("error while creating new StatsD client, giving up: %v", err)
} else {
s.state.clientsLock.Lock()
for _, client := range s.state.pendingClients {
client.statsd = s.state.client.statsd.Clone(s.state.conn, s.statsdConfig.statsdTagsFormat(), s.statsdConfig.statsdDefaultTags(), statsd.Tags(client.tags...), statsd.SampleRate(client.samplingRate))
}

s.logger.Info("statsd client setup succeeded.")
s.logger.Info("StatsD client setup succeeded.")
s.state.connEstablished = true
s.state.pendingClients = nil
s.state.clientsLock.Unlock()
Expand All @@ -79,7 +81,7 @@ func (s *statsdStats) getNewStatsdClientWithExpoBackoff(ctx context.Context, opt
op := func() error {
c, err = statsd.New(opts...)
if err != nil {
s.logger.Errorf("error while setting statsd client: %v", err)
s.logger.Errorf("error while creating new StatsD client: %v", err)
}
return err
}
Expand Down