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: 3 additions & 2 deletions cmd/otelcorecol/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

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

go 1.22.0
go 1.23
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we want this changed in this PR?

Suggested change
go 1.23
go 1.22.0

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh but it looks like backoff v5 requires Go 1.23

$ make gotidy
...
go: github.com/cenkalti/backoff/[email protected] requires go >= 1.23 (running go 1.22.10)
...


toolchain go1.22.10
toolchain go1.23.3

require (
go.opentelemetry.io/collector/component v0.116.0
Expand Down Expand Up @@ -37,6 +37,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
6 changes: 4 additions & 2 deletions config/configretry/go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
module go.opentelemetry.io/collector/config/configretry

go 1.22.0
go 1.23

toolchain go1.23.3

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.

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

go 1.22.0
go 1.23

toolchain go1.23.3

require (
github.com/stretchr/testify v1.10.0
Expand All @@ -22,7 +24,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
14 changes: 8 additions & 6 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,7 +65,7 @@ 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
Copy link
Member

@andrzej-stencel andrzej-stencel Jan 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since backoff v5 does not call Reset anymore (see cenkalti/backoff@3d3869e#diff-ee852aa38e35ae3dd2c77fb33fb1f19c99b3d1db494938776be798950279db26L86), this comment should be removed. We could also theoretically now use the NewExponentialBackoff function (not sure if it brings us any value).

// call Reset after changing the InitialInterval (this saves an unnecessary call to Now).
Expand All @@ -74,13 +74,15 @@ func (rs *retrySender) Send(ctx context.Context, req internal.Request) error {
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)
if rs.cfg.MaxElapsedTime > 0 {
var cancel context.CancelFunc
ctx, cancel = context.WithTimeout(ctx, rs.cfg.MaxElapsedTime)
// releases resources if operation completes before timeout elapses
defer cancel()
}
for {
span.AddEvent(
"Sending request.",
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
6 changes: 4 additions & 2 deletions exporter/exporterhelper/xexporterhelper/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module go.opentelemetry.io/collector/exporter/exporterhelper/xexporterhelper

go 1.22.0
go 1.23

toolchain go1.23.3

require (
github.com/stretchr/testify v1.10.0
Expand All @@ -25,7 +27,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.

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

go 1.22.0
go 1.23

toolchain go1.23.3

require (
github.com/google/uuid v1.6.0
Expand All @@ -22,7 +24,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.

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

go 1.22.0
go 1.23

toolchain go1.23.3

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: 2 additions & 0 deletions exporter/nopexporter/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ module go.opentelemetry.io/collector/exporter/nopexporter

go 1.22.0

toolchain go1.23.3

require (
github.com/stretchr/testify v1.10.0
go.opentelemetry.io/collector/component v0.116.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.

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

go 1.22.0
go 1.23

toolchain go1.23.3

require (
github.com/stretchr/testify v1.10.0
Expand Down Expand Up @@ -31,7 +33,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.

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

go 1.22.0
go 1.23

toolchain go1.23.3

require (
github.com/stretchr/testify v1.10.0
Expand Down Expand Up @@ -29,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/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: 2 additions & 0 deletions exporter/xexporter/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ module go.opentelemetry.io/collector/exporter/xexporter

go 1.22.0

toolchain go1.23.3

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

go 1.22.0
go 1.23

toolchain go1.23.3

require (
github.com/stretchr/testify v1.10.0
Expand Down Expand Up @@ -39,6 +41,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: 1 addition & 1 deletion internal/tools/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module go.opentelemetry.io/collector/internal/tools

go 1.23

toolchain go1.23.2
toolchain go1.23.3

require (
github.com/a8m/envsubst v1.4.2
Expand Down
4 changes: 3 additions & 1 deletion otelcol/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module go.opentelemetry.io/collector/otelcol

go 1.22.0
go 1.23

toolchain go1.23.3

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.

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

go 1.22.0
go 1.23

toolchain go1.23.3

require (
github.com/stretchr/testify v1.10.0
Expand Down
Loading
Loading