Skip to content

Commit

Permalink
Fix metrics reporter retry logic (#700)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhurley authored Jun 10, 2024
1 parent fc1db22 commit 1c25b60
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 12 deletions.
14 changes: 11 additions & 3 deletions sdk/client/metric_reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ func (r *metricReporter) createClient() error {
r.channel = channel
r.eventsChannel = eventsChannel

r.isRetrying = false

return nil
}

Expand Down Expand Up @@ -165,12 +167,12 @@ func (r *metricReporter) Send(ctx context.Context, message Message) error {
}

if r.channel == nil {
r.isRetrying = true
r.setIsRetrying(true)
return r.handleGrpcError("Metric Reporter Channel Send", errors.New("metric service stream client not created yet"))
}

if err := r.channel.Send(report); err != nil {
r.isRetrying = true
r.setIsRetrying(true)
return r.handleGrpcError("Metric Reporter Channel Send", err)
}

Expand All @@ -191,7 +193,7 @@ func (r *metricReporter) Send(ctx context.Context, message Message) error {
}

if err := r.eventsChannel.Send(report); err != nil {
r.isRetrying = true
r.setIsRetrying(true)
return r.handleGrpcError("Metric Reporter Events Channel Send", err)
}

Expand Down Expand Up @@ -259,3 +261,9 @@ func (r *metricReporter) handleGrpcError(messagePrefix string, err error) error

return err
}

func (r *metricReporter) setIsRetrying(value bool) {
r.retryLock.Lock()
defer r.retryLock.Unlock()
r.isRetrying = value
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1c25b60

Please sign in to comment.