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

Fix metrics reporter retry logic #700

Merged
merged 1 commit into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
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
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)
oliveromahony marked this conversation as resolved.
Show resolved Hide resolved
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.

14 changes: 11 additions & 3 deletions vendor/github.com/nginx/agent/sdk/v2/client/metric_reporter.go

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

Loading