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

Update module github.com/cenkalti/backoff/v4 to v5 #11989

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
5 changes: 2 additions & 3 deletions cmd/otelcorecol/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

module go.opentelemetry.io/collector/cmd/otelcorecol

go 1.22.0

toolchain go1.22.10
go 1.23
bogdandrutu marked this conversation as resolved.
Show resolved Hide resolved

require (
go.opentelemetry.io/collector/component v0.116.0
Expand Down Expand Up @@ -37,6 +35,7 @@ require (
require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cenkalti/backoff/v5 v5.0.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/ebitengine/purego v0.8.1 // indirect
Expand Down
2 changes: 2 additions & 0 deletions cmd/otelcorecol/go.sum

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

2 changes: 1 addition & 1 deletion config/configretry/backoff.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"errors"
"time"

"github.com/cenkalti/backoff/v4"
"github.com/cenkalti/backoff/v5"
)

// NewDefaultBackOffConfig returns the default settings for RetryConfig.
Expand Down
4 changes: 2 additions & 2 deletions config/configretry/go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module go.opentelemetry.io/collector/config/configretry

go 1.22.0
go 1.23

require (
github.com/cenkalti/backoff/v4 v4.3.0
github.com/cenkalti/backoff/v5 v5.0.0
github.com/stretchr/testify v1.10.0
go.uber.org/goleak v1.3.0
)
Expand Down
4 changes: 2 additions & 2 deletions config/configretry/go.sum

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

4 changes: 2 additions & 2 deletions exporter/debugexporter/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module go.opentelemetry.io/collector/exporter/debugexporter

go 1.22.0
go 1.23

require (
github.com/stretchr/testify v1.10.0
Expand All @@ -22,7 +22,7 @@ require (
)

require (
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cenkalti/backoff/v5 v5.0.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
Expand Down
4 changes: 2 additions & 2 deletions exporter/debugexporter/go.sum

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

5 changes: 4 additions & 1 deletion exporter/exporterhelper/internal/queue_sender_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ func TestQueuedRetryHappyPath(t *testing.T) {
) {
t.Run(testName, func(t *testing.T) {
resetFeatureGate := setFeatureGateForTest(t, usePullingBasedExporterQueueBatcher, enableQueueBatcher)
t.Cleanup(func() {
resetFeatureGate()
})

tel, err := componenttest.SetupTelemetry(defaultID)
require.NoError(t, err)
t.Cleanup(func() { require.NoError(t, tel.Shutdown(context.Background())) })
Expand All @@ -221,7 +225,6 @@ func TestQueuedRetryHappyPath(t *testing.T) {
require.NoError(t, be.Start(context.Background(), componenttest.NewNopHost()))
t.Cleanup(func() {
assert.NoError(t, be.Shutdown(context.Background()))
resetFeatureGate()
})

// Wait until all batches received
Expand Down
22 changes: 13 additions & 9 deletions exporter/exporterhelper/internal/retry_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"fmt"
"time"

"github.com/cenkalti/backoff/v4"
"github.com/cenkalti/backoff/v5"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
"go.uber.org/zap"
Expand Down Expand Up @@ -65,22 +65,20 @@ func (rs *retrySender) Shutdown(context.Context) error {
return nil
}

// send implements the requestSender interface
// Send implements the requestSender interface
func (rs *retrySender) Send(ctx context.Context, req internal.Request) error {
// Do not use NewExponentialBackOff since it calls Reset and the code here must
// call Reset after changing the InitialInterval (this saves an unnecessary call to Now).
expBackoff := backoff.ExponentialBackOff{
InitialInterval: rs.cfg.InitialInterval,
RandomizationFactor: rs.cfg.RandomizationFactor,
Multiplier: rs.cfg.Multiplier,
MaxInterval: rs.cfg.MaxInterval,
MaxElapsedTime: rs.cfg.MaxElapsedTime,
Stop: backoff.Stop,
Clock: backoff.SystemClock,
}
expBackoff.Reset()
span := trace.SpanFromContext(ctx)
retryNum := int64(0)
var maxElapsedTime time.Time
if rs.cfg.MaxElapsedTime > 0 {
maxElapsedTime = time.Now().Add(rs.cfg.MaxElapsedTime)
}
for {
span.AddEvent(
"Sending request.",
Expand Down Expand Up @@ -110,7 +108,13 @@ func (rs *retrySender) Send(ctx context.Context, req internal.Request) error {
backoffDelay = max(backoffDelay, throttleErr.delay)
}

if deadline, has := ctx.Deadline(); has && time.Until(deadline) < backoffDelay {
nextRetryTime := time.Now().Add(backoffDelay)
if !maxElapsedTime.IsZero() && maxElapsedTime.Before(nextRetryTime) {
// The delay is longer than the maxElapsedTime.
return fmt.Errorf("no more retries left: %w", err)
}

if deadline, has := ctx.Deadline(); has && deadline.Before(nextRetryTime) {
// The delay is longer than the deadline. There is no point in
// waiting for cancelation.
return fmt.Errorf("request will be cancelled before next retry: %w", err)
Expand Down
8 changes: 3 additions & 5 deletions exporter/exporterhelper/internal/retry_sender_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,10 @@ func TestQueueRetryWithDisabledRetires(t *testing.T) {
ocs.run(func() {
require.Error(t, be.Send(context.Background(), mockR))
})
ocs.awaitAsyncProcessing()
assert.Len(t, observed.All(), 1)
assert.Equal(t, "Exporting failed. Rejecting data. "+
"Try enabling retry_on_failure config option to retry on retryable errors.", observed.All()[0].Message)
ocs.awaitAsyncProcessing()
mockR.checkNumRequests(t, 1)
ocs.checkSendItemsCount(t, 0)
ocs.checkDroppedItemsCount(t, 2)
Expand Down Expand Up @@ -367,15 +367,13 @@ func TestRetryWithContextTimeout(t *testing.T) {
ocs.run(func() {
ctx, cancel := context.WithTimeout(context.Background(), testTimeout)
defer cancel()
err := be.Send(ctx, mockR)
require.Error(t, err)
require.Equal(t, "request will be cancelled before next retry: transient error", err.Error())
require.EqualError(t, be.Send(ctx, mockR), "request will be cancelled before next retry: transient error")
})
ocs.awaitAsyncProcessing()
assert.Len(t, observed.All(), 2)
assert.Equal(t, "Exporting failed. Will retry the request after interval.", observed.All()[0].Message)
assert.Equal(t, "Exporting failed. Rejecting data. "+
"Try enabling sending_queue to survive temporary failures.", observed.All()[1].Message)
ocs.awaitAsyncProcessing()
ocs.checkDroppedItemsCount(t, 7)
require.Equal(t, 2, mockR.(*mockErrorRequest).getNumRequests())
require.NoError(t, be.Shutdown(context.Background()))
Expand Down
4 changes: 2 additions & 2 deletions exporter/exporterhelper/xexporterhelper/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module go.opentelemetry.io/collector/exporter/exporterhelper/xexporterhelper

go 1.22.0
go 1.23

require (
github.com/stretchr/testify v1.10.0
Expand All @@ -25,7 +25,7 @@ require (
)

require (
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cenkalti/backoff/v5 v5.0.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
Expand Down
4 changes: 2 additions & 2 deletions exporter/exporterhelper/xexporterhelper/go.sum

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

4 changes: 2 additions & 2 deletions exporter/exportertest/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module go.opentelemetry.io/collector/exporter/exportertest

go 1.22.0
go 1.23

require (
github.com/google/uuid v1.6.0
Expand All @@ -22,7 +22,7 @@ require (
)

require (
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cenkalti/backoff/v5 v5.0.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
Expand Down
4 changes: 2 additions & 2 deletions exporter/exportertest/go.sum

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

4 changes: 2 additions & 2 deletions exporter/go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module go.opentelemetry.io/collector/exporter

go 1.22.0
go 1.23

require (
github.com/cenkalti/backoff/v4 v4.3.0
github.com/cenkalti/backoff/v5 v5.0.0
github.com/stretchr/testify v1.10.0
go.opentelemetry.io/collector/component v0.116.0
go.opentelemetry.io/collector/component/componenttest v0.116.0
Expand Down
4 changes: 2 additions & 2 deletions exporter/go.sum

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

2 changes: 1 addition & 1 deletion exporter/nopexporter/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module go.opentelemetry.io/collector/exporter/nopexporter

go 1.22.0
go 1.23

require (
github.com/stretchr/testify v1.10.0
Expand Down
4 changes: 2 additions & 2 deletions exporter/nopexporter/go.sum

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

4 changes: 2 additions & 2 deletions exporter/otlpexporter/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module go.opentelemetry.io/collector/exporter/otlpexporter

go 1.22.0
go 1.23

require (
github.com/stretchr/testify v1.10.0
Expand Down Expand Up @@ -31,7 +31,7 @@ require (
)

require (
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cenkalti/backoff/v5 v5.0.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fsnotify/fsnotify v1.8.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
Expand Down
4 changes: 2 additions & 2 deletions exporter/otlpexporter/go.sum

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

4 changes: 2 additions & 2 deletions exporter/otlphttpexporter/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module go.opentelemetry.io/collector/exporter/otlphttpexporter

go 1.22.0
go 1.23

require (
github.com/stretchr/testify v1.10.0
Expand Down Expand Up @@ -29,7 +29,7 @@ require (
)

require (
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cenkalti/backoff/v5 v5.0.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.8.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions exporter/otlphttpexporter/go.sum

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

2 changes: 1 addition & 1 deletion exporter/xexporter/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module go.opentelemetry.io/collector/exporter/xexporter

go 1.22.0
go 1.23

require (
github.com/stretchr/testify v1.10.0
Expand Down
3 changes: 2 additions & 1 deletion internal/e2e/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module go.opentelemetry.io/collector/internal/e2e

go 1.22.0
go 1.23

require (
github.com/stretchr/testify v1.10.0
Expand Down Expand Up @@ -39,6 +39,7 @@ require (
require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cenkalti/backoff/v5 v5.0.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/ebitengine/purego v0.8.1 // indirect
Expand Down
2 changes: 2 additions & 0 deletions internal/e2e/go.sum

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

2 changes: 0 additions & 2 deletions internal/tools/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ module go.opentelemetry.io/collector/internal/tools

go 1.23

toolchain go1.23.2

require (
github.com/a8m/envsubst v1.4.2
github.com/client9/misspell v0.3.4
Expand Down
2 changes: 1 addition & 1 deletion otelcol/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module go.opentelemetry.io/collector/otelcol

go 1.22.0
go 1.23

require (
github.com/spf13/cobra v1.8.1
Expand Down
2 changes: 2 additions & 0 deletions otelcol/go.sum

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

2 changes: 1 addition & 1 deletion otelcol/otelcoltest/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module go.opentelemetry.io/collector/otelcol/otelcoltest

go 1.22.0
go 1.23

require (
github.com/stretchr/testify v1.10.0
Expand Down
2 changes: 2 additions & 0 deletions otelcol/otelcoltest/go.sum

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

Loading
Loading