From 35601886feffa9d56174e546a8ce3071dca04ee7 Mon Sep 17 00:00:00 2001 From: Bogdan Drutu Date: Tue, 12 Dec 2023 12:38:29 -0800 Subject: [PATCH] Deprecate exporterhelper.RetrySettings in favor of configretry.BackOffSettings Signed-off-by: Bogdan Drutu --- .chloggen/deprecateretry.yaml | 13 +++ cmd/otelcorecol/builder-config.yaml | 1 + cmd/otelcorecol/go.mod | 3 + component/host.go | 2 +- config/configgrpc/go.mod | 6 +- config/confighttp/go.mod | 2 + config/configretry/Makefile | 1 + config/configretry/backoff.go | 65 +++++++++++++++ config/configretry/backoff_test.go | 70 ++++++++++++++++ config/configretry/go.mod | 17 ++++ config/configretry/go.sum | 25 ++++++ connector/forwardconnector/go.mod | 2 + connector/go.mod | 2 + consumer/go.mod | 2 + exporter/debugexporter/go.mod | 3 + exporter/exporterhelper/common.go | 7 +- exporter/exporterhelper/common_test.go | 7 +- exporter/exporterhelper/logs_test.go | 5 +- exporter/exporterhelper/metrics_test.go | 5 +- exporter/exporterhelper/queue_sender_test.go | 23 +++--- exporter/exporterhelper/retry_sender.go | 61 ++------------ exporter/exporterhelper/retry_sender_test.go | 80 +++---------------- exporter/exporterhelper/traces_test.go | 5 +- .../exportertest/contract_checker_test.go | 5 +- exporter/go.mod | 3 +- exporter/loggingexporter/go.mod | 3 + exporter/otlpexporter/config.go | 3 +- exporter/otlpexporter/config_test.go | 3 +- .../otlpexporter/consume_contract_test.go | 3 +- exporter/otlpexporter/factory.go | 3 +- exporter/otlpexporter/factory_test.go | 3 +- exporter/otlpexporter/go.mod | 3 + exporter/otlphttpexporter/config.go | 3 +- exporter/otlphttpexporter/config_test.go | 3 +- exporter/otlphttpexporter/factory.go | 3 +- exporter/otlphttpexporter/go.mod | 3 + extension/ballastextension/go.mod | 2 + extension/zpagesextension/go.mod | 2 + go.mod | 3 + otelcol/go.mod | 2 + processor/batchprocessor/go.mod | 2 + processor/go.mod | 2 + processor/memorylimiterprocessor/go.mod | 2 + receiver/go.mod | 2 + receiver/otlpreceiver/go.mod | 2 + service/go.mod | 2 + versions.yaml | 1 + 47 files changed, 308 insertions(+), 162 deletions(-) create mode 100755 .chloggen/deprecateretry.yaml create mode 100644 config/configretry/Makefile create mode 100644 config/configretry/backoff.go create mode 100644 config/configretry/backoff_test.go create mode 100644 config/configretry/go.mod create mode 100644 config/configretry/go.sum diff --git a/.chloggen/deprecateretry.yaml b/.chloggen/deprecateretry.yaml new file mode 100755 index 000000000000..88adb20bac1e --- /dev/null +++ b/.chloggen/deprecateretry.yaml @@ -0,0 +1,13 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: 'deprecation' + +# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver) +component: "exporterhelper" + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: "Deprecate exporterhelper.RetrySettings in favor of configretry.BackOffSettings" + +# One or more tracking issues or pull requests related to the change +issues: [9091] diff --git a/cmd/otelcorecol/builder-config.yaml b/cmd/otelcorecol/builder-config.yaml index 60414f8d0d76..dd0a5087f209 100644 --- a/cmd/otelcorecol/builder-config.yaml +++ b/cmd/otelcorecol/builder-config.yaml @@ -31,6 +31,7 @@ replaces: - go.opentelemetry.io/collector/config/confighttp => ../../config/confighttp - go.opentelemetry.io/collector/config/confignet => ../../config/confignet - go.opentelemetry.io/collector/config/configopaque => ../../config/configopaque + - go.opentelemetry.io/collector/config/configretry => ../config/configretry - go.opentelemetry.io/collector/config/configtelemetry => ../../config/configtelemetry - go.opentelemetry.io/collector/config/configtls => ../../config/configtls - go.opentelemetry.io/collector/config/internal => ../../config/internal diff --git a/cmd/otelcorecol/go.mod b/cmd/otelcorecol/go.mod index 56d5749dc8d0..8f550775d2da 100644 --- a/cmd/otelcorecol/go.mod +++ b/cmd/otelcorecol/go.mod @@ -84,6 +84,7 @@ require ( go.opentelemetry.io/collector/config/confighttp v0.91.0 // indirect go.opentelemetry.io/collector/config/confignet v0.91.0 // indirect go.opentelemetry.io/collector/config/configopaque v0.91.0 // indirect + go.opentelemetry.io/collector/config/configretry v0.91.0 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/collector/config/configtls v0.91.0 // indirect go.opentelemetry.io/collector/config/internal v0.91.0 // indirect @@ -146,6 +147,8 @@ replace go.opentelemetry.io/collector/config/confignet => ../../config/confignet replace go.opentelemetry.io/collector/config/configopaque => ../../config/configopaque +replace go.opentelemetry.io/collector/config/configretry => ../../config/configretry + replace go.opentelemetry.io/collector/config/configtelemetry => ../../config/configtelemetry replace go.opentelemetry.io/collector/config/configtls => ../../config/configtls diff --git a/component/host.go b/component/host.go index 732e37c8c44b..e3b9ea32a39f 100644 --- a/component/host.go +++ b/component/host.go @@ -50,7 +50,7 @@ type Host interface { // GetExporters can be called by the component anytime after Component.Start() begins and // until Component.Shutdown() ends. // - // Deprecated: [0.79.0] This function will be removed in the future. + // Deprecated: `[0.79.0]` This function will be removed in the future. // Several components in the contrib repository use this function so it cannot be removed // before those cases are removed. In most cases, use of this function can be replaced by a // connector. See https://github.com/open-telemetry/opentelemetry-collector/issues/7370 and diff --git a/config/configgrpc/go.mod b/config/configgrpc/go.mod index 2655e2df495a..7457f3f9af8f 100644 --- a/config/configgrpc/go.mod +++ b/config/configgrpc/go.mod @@ -86,6 +86,8 @@ replace go.opentelemetry.io/collector/config/configopaque => ../configopaque replace go.opentelemetry.io/collector/config/configtls => ../configtls +replace go.opentelemetry.io/collector/config/configretry => ../../config/configretry + replace go.opentelemetry.io/collector/config/configtelemetry => ../configtelemetry replace go.opentelemetry.io/collector/config/internal => ../internal @@ -102,8 +104,6 @@ replace go.opentelemetry.io/collector/exporter => ../../exporter replace go.opentelemetry.io/collector/receiver => ../../receiver -replace go.opentelemetry.io/collector/connector => ../../connector - replace go.opentelemetry.io/collector/featuregate => ../../featuregate replace go.opentelemetry.io/collector/pdata => ../../pdata @@ -111,3 +111,5 @@ replace go.opentelemetry.io/collector/pdata => ../../pdata replace go.opentelemetry.io/collector/component => ../../component replace go.opentelemetry.io/collector/consumer => ../../consumer + +replace go.opentelemetry.io/collector/connector => ../../connector diff --git a/config/confighttp/go.mod b/config/confighttp/go.mod index a9887e394949..7660adb60c43 100644 --- a/config/confighttp/go.mod +++ b/config/confighttp/go.mod @@ -88,3 +88,5 @@ replace go.opentelemetry.io/collector/pdata => ../../pdata replace go.opentelemetry.io/collector/component => ../../component replace go.opentelemetry.io/collector/consumer => ../../consumer + +replace go.opentelemetry.io/collector/config/configretry => ../configretry diff --git a/config/configretry/Makefile b/config/configretry/Makefile new file mode 100644 index 000000000000..ded7a36092dc --- /dev/null +++ b/config/configretry/Makefile @@ -0,0 +1 @@ +include ../../Makefile.Common diff --git a/config/configretry/backoff.go b/config/configretry/backoff.go new file mode 100644 index 000000000000..f80f969781e7 --- /dev/null +++ b/config/configretry/backoff.go @@ -0,0 +1,65 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package configretry + +import ( + "errors" + "time" + + "github.com/cenkalti/backoff/v4" +) + +// NewDefaultBackOffSettings returns the default settings for RetrySettings. +func NewDefaultBackOffSettings() BackOffSettings { + return BackOffSettings{ + Enabled: true, + InitialInterval: 5 * time.Second, + RandomizationFactor: backoff.DefaultRandomizationFactor, + Multiplier: backoff.DefaultMultiplier, + MaxInterval: 30 * time.Second, + MaxElapsedTime: 5 * time.Minute, + } +} + +// BackOffSettings defines configuration for retrying batches in case of export failure. +// The current supported strategy is exponential backoff. +type BackOffSettings struct { + // Enabled indicates whether to not retry sending batches in case of export failure. + Enabled bool `mapstructure:"enabled"` + // InitialInterval the time to wait after the first failure before retrying. + InitialInterval time.Duration `mapstructure:"initial_interval"` + // RandomizationFactor is a random factor used to calculate next backoffs + // Randomized interval = RetryInterval * (1 ± RandomizationFactor) + RandomizationFactor float64 `mapstructure:"randomization_factor"` + // Multiplier is the value multiplied by the backoff interval bounds + Multiplier float64 `mapstructure:"multiplier"` + // MaxInterval is the upper bound on backoff interval. Once this value is reached the delay between + // consecutive retries will always be `MaxInterval`. + MaxInterval time.Duration `mapstructure:"max_interval"` + // MaxElapsedTime is the maximum amount of time (including retries) spent trying to send a request/batch. + // Once this value is reached, the data is discarded. + MaxElapsedTime time.Duration `mapstructure:"max_elapsed_time"` +} + +func (bs *BackOffSettings) Validate() error { + if !bs.Enabled { + return nil + } + if bs.InitialInterval < 0 { + return errors.New("initial interval must be non-negative") + } + if bs.RandomizationFactor < 0 || bs.RandomizationFactor > 1 { + return errors.New("randomization factor must be within [0, 1]") + } + if bs.Multiplier <= 0 { + return errors.New("multiplier must be positive") + } + if bs.MaxInterval < 0 { + return errors.New("max interval must be non-negative") + } + if bs.MaxElapsedTime < 0 { + return errors.New("max elapsed time must be non-negative") + } + return nil +} diff --git a/config/configretry/backoff_test.go b/config/configretry/backoff_test.go new file mode 100644 index 000000000000..57ddd1b9cf3f --- /dev/null +++ b/config/configretry/backoff_test.go @@ -0,0 +1,70 @@ +package configretry + +import ( + "github.com/stretchr/testify/assert" + "testing" + "time" +) + +func TestNewDefaultBackOffSettings(t *testing.T) { + cfg := NewDefaultBackOffSettings() + assert.NoError(t, cfg.Validate()) + assert.Equal(t, + BackOffSettings{ + Enabled: true, + InitialInterval: 5 * time.Second, + RandomizationFactor: 0.5, + Multiplier: 1.5, + MaxInterval: 30 * time.Second, + MaxElapsedTime: 5 * time.Minute, + }, cfg) +} + +func TestInvalidInitialInterval(t *testing.T) { + cfg := NewDefaultBackOffSettings() + assert.NoError(t, cfg.Validate()) + cfg.InitialInterval = -1 + assert.Error(t, cfg.Validate()) +} + +func TestInvalidRandomizationFactor(t *testing.T) { + cfg := NewDefaultBackOffSettings() + assert.NoError(t, cfg.Validate()) + cfg.RandomizationFactor = -1 + assert.Error(t, cfg.Validate()) + cfg.RandomizationFactor = 2 + assert.Error(t, cfg.Validate()) +} + +func TestInvalidMultiplier(t *testing.T) { + cfg := NewDefaultBackOffSettings() + assert.NoError(t, cfg.Validate()) + cfg.Multiplier = 0 + assert.Error(t, cfg.Validate()) +} + +func TestInvalidMaxInterval(t *testing.T) { + cfg := NewDefaultBackOffSettings() + assert.NoError(t, cfg.Validate()) + cfg.MaxInterval = -1 + assert.Error(t, cfg.Validate()) +} + +func TestInvalidMaxElapsedTime(t *testing.T) { + cfg := NewDefaultBackOffSettings() + assert.NoError(t, cfg.Validate()) + cfg.MaxElapsedTime = -1 + assert.Error(t, cfg.Validate()) +} + +func TestDisabledWithInvalidValues(t *testing.T) { + cfg := BackOffSettings{ + Enabled: false, + InitialInterval: -1, + RandomizationFactor: -1, + Multiplier: 0, + MaxInterval: -1, + MaxElapsedTime: -1, + } + assert.NoError(t, cfg.Validate()) +} diff --git a/config/configretry/go.mod b/config/configretry/go.mod new file mode 100644 index 000000000000..054a91e92f63 --- /dev/null +++ b/config/configretry/go.mod @@ -0,0 +1,17 @@ +module go.opentelemetry.io/collector/config/configretry + +go 1.20 + +require ( + github.com/cenkalti/backoff/v4 v4.2.1 + github.com/stretchr/testify v1.8.4 +) + +require ( + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/kr/pretty v0.3.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/rogpeppe/go-internal v1.10.0 // indirect + gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/config/configretry/go.sum b/config/configretry/go.sum new file mode 100644 index 000000000000..f782e6a3ba9f --- /dev/null +++ b/config/configretry/go.sum @@ -0,0 +1,25 @@ +github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= +github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= +github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/connector/forwardconnector/go.mod b/connector/forwardconnector/go.mod index 39e070a47734..3758276928a1 100644 --- a/connector/forwardconnector/go.mod +++ b/connector/forwardconnector/go.mod @@ -71,3 +71,5 @@ retract ( ) replace go.opentelemetry.io/collector/config/configtelemetry => ../../config/configtelemetry + +replace go.opentelemetry.io/collector/config/configretry => ../../config/configretry diff --git a/connector/go.mod b/connector/go.mod index f11308b2495d..59fbd3f7260c 100644 --- a/connector/go.mod +++ b/connector/go.mod @@ -63,3 +63,5 @@ replace go.opentelemetry.io/collector/processor => ../processor replace go.opentelemetry.io/collector/receiver => ../receiver replace go.opentelemetry.io/collector/exporter => ../exporter + +replace go.opentelemetry.io/collector/config/configretry => ../config/configretry diff --git a/consumer/go.mod b/consumer/go.mod index 7d42f9e326ab..9f19b8daa029 100644 --- a/consumer/go.mod +++ b/consumer/go.mod @@ -53,3 +53,5 @@ retract ( replace go.opentelemetry.io/collector/connector => ../connector replace go.opentelemetry.io/collector/config/configtelemetry => ../config/configtelemetry + +replace go.opentelemetry.io/collector/config/configretry => ../config/configretry diff --git a/exporter/debugexporter/go.mod b/exporter/debugexporter/go.mod index 1ae440033dae..ec1f1df02133 100644 --- a/exporter/debugexporter/go.mod +++ b/exporter/debugexporter/go.mod @@ -28,6 +28,7 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect go.opencensus.io v0.24.0 // indirect go.opentelemetry.io/collector v0.91.0 // indirect + go.opentelemetry.io/collector/config/configretry v0.91.0 // indirect go.opentelemetry.io/collector/consumer v0.91.0 // indirect go.opentelemetry.io/collector/extension v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect @@ -70,3 +71,5 @@ replace go.opentelemetry.io/collector/connector => ../../connector replace go.opentelemetry.io/collector/processor => ../../processor replace go.opentelemetry.io/collector/config/configtelemetry => ../../config/configtelemetry + +replace go.opentelemetry.io/collector/config/configretry => ../../config/configretry diff --git a/exporter/exporterhelper/common.go b/exporter/exporterhelper/common.go index 69fb3771d857..b528eb19a927 100644 --- a/exporter/exporterhelper/common.go +++ b/exporter/exporterhelper/common.go @@ -5,6 +5,7 @@ package exporterhelper // import "go.opentelemetry.io/collector/exporter/exporte import ( "context" + "go.opentelemetry.io/collector/config/configretry" "go.uber.org/multierr" "go.uber.org/zap" @@ -80,9 +81,9 @@ func WithTimeout(timeoutSettings TimeoutSettings) Option { } } -// WithRetry overrides the default RetrySettings for an exporter. -// The default RetrySettings is to disable retries. -func WithRetry(config RetrySettings) Option { +// WithRetry overrides the default configretry.BackOffSettings for an exporter. +// The default configretry.BackOffSettings is to disable retries. +func WithRetry(config configretry.BackOffSettings) Option { return func(o *baseExporter) { if !config.Enabled { o.retrySender = &errorLoggingRequestSender{ diff --git a/exporter/exporterhelper/common_test.go b/exporter/exporterhelper/common_test.go index 0e74e0951470..49069793b80f 100644 --- a/exporter/exporterhelper/common_test.go +++ b/exporter/exporterhelper/common_test.go @@ -17,6 +17,7 @@ import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/component/componenttest" + "go.opentelemetry.io/collector/config/configretry" "go.opentelemetry.io/collector/exporter" "go.opentelemetry.io/collector/exporter/exportertest" ) @@ -73,12 +74,12 @@ func checkStatus(t *testing.T, sd sdktrace.ReadOnlySpan, err error) { func TestQueueRetryOptionsWithRequestExporter(t *testing.T) { bs, err := newBaseExporter(exportertest.NewNopCreateSettings(), "", true, nil, nil, newNoopObsrepSender, - WithRetry(NewDefaultRetrySettings())) + WithRetry(configretry.NewDefaultBackOffSettings())) require.Nil(t, err) require.True(t, bs.requestExporter) require.Panics(t, func() { _, _ = newBaseExporter(exportertest.NewNopCreateSettings(), "", true, nil, nil, newNoopObsrepSender, - WithRetry(NewDefaultRetrySettings()), WithQueue(NewDefaultQueueSettings())) + WithRetry(configretry.NewDefaultBackOffSettings()), WithQueue(NewDefaultQueueSettings())) }) } @@ -86,7 +87,7 @@ func TestBaseExporterLogging(t *testing.T) { set := exportertest.NewNopCreateSettings() logger, observed := observer.New(zap.DebugLevel) set.Logger = zap.New(logger) - rCfg := NewDefaultRetrySettings() + rCfg := configretry.NewDefaultBackOffSettings() rCfg.Enabled = false bs, err := newBaseExporter(set, "", true, nil, nil, newNoopObsrepSender, WithRetry(rCfg)) require.Nil(t, err) diff --git a/exporter/exporterhelper/logs_test.go b/exporter/exporterhelper/logs_test.go index feaa9948323e..92d48ffd48bd 100644 --- a/exporter/exporterhelper/logs_test.go +++ b/exporter/exporterhelper/logs_test.go @@ -20,6 +20,7 @@ import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/component/componenttest" + "go.opentelemetry.io/collector/config/configretry" "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/consumer/consumererror" "go.opentelemetry.io/collector/consumer/consumertest" @@ -159,7 +160,7 @@ func TestLogsExporter_WithPersistentQueue(t *testing.T) { qCfg := NewDefaultQueueSettings() storageID := component.NewIDWithName("file_storage", "storage") qCfg.StorageID = &storageID - rCfg := NewDefaultRetrySettings() + rCfg := configretry.NewDefaultBackOffSettings() ts := consumertest.LogsSink{} set := exportertest.NewNopCreateSettings() set.ID = component.NewIDWithName("test_logs", "with_persistent_queue") @@ -237,7 +238,7 @@ func TestLogsExporter_WithRecordEnqueueFailedMetrics(t *testing.T) { require.NoError(t, err) t.Cleanup(func() { require.NoError(t, tt.Shutdown(context.Background())) }) - rCfg := NewDefaultRetrySettings() + rCfg := configretry.NewDefaultBackOffSettings() qCfg := NewDefaultQueueSettings() qCfg.NumConsumers = 1 qCfg.QueueSize = 2 diff --git a/exporter/exporterhelper/metrics_test.go b/exporter/exporterhelper/metrics_test.go index 57a01a302437..628c08fc13de 100644 --- a/exporter/exporterhelper/metrics_test.go +++ b/exporter/exporterhelper/metrics_test.go @@ -20,6 +20,7 @@ import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/component/componenttest" + "go.opentelemetry.io/collector/config/configretry" "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/consumer/consumererror" "go.opentelemetry.io/collector/consumer/consumertest" @@ -160,7 +161,7 @@ func TestMetricsExporter_WithPersistentQueue(t *testing.T) { qCfg := NewDefaultQueueSettings() storageID := component.NewIDWithName("file_storage", "storage") qCfg.StorageID = &storageID - rCfg := NewDefaultRetrySettings() + rCfg := configretry.NewDefaultBackOffSettings() ms := consumertest.MetricsSink{} set := exportertest.NewNopCreateSettings() set.ID = component.NewIDWithName("test_metrics", "with_persistent_queue") @@ -239,7 +240,7 @@ func TestMetricsExporter_WithRecordEnqueueFailedMetrics(t *testing.T) { require.NoError(t, err) t.Cleanup(func() { require.NoError(t, tt.Shutdown(context.Background())) }) - rCfg := NewDefaultRetrySettings() + rCfg := configretry.NewDefaultBackOffSettings() qCfg := NewDefaultQueueSettings() qCfg.NumConsumers = 1 qCfg.QueueSize = 2 diff --git a/exporter/exporterhelper/queue_sender_test.go b/exporter/exporterhelper/queue_sender_test.go index b3e3cf084ec6..10b6f11f90b5 100644 --- a/exporter/exporterhelper/queue_sender_test.go +++ b/exporter/exporterhelper/queue_sender_test.go @@ -16,6 +16,7 @@ import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/component/componenttest" + "go.opentelemetry.io/collector/config/configretry" "go.opentelemetry.io/collector/exporter" "go.opentelemetry.io/collector/exporter/exporterhelper/internal" "go.opentelemetry.io/collector/exporter/exportertest" @@ -27,7 +28,7 @@ import ( func TestQueuedRetry_StopWhileWaiting(t *testing.T) { qCfg := NewDefaultQueueSettings() qCfg.NumConsumers = 1 - rCfg := NewDefaultRetrySettings() + rCfg := configretry.NewDefaultBackOffSettings() be, err := newBaseExporter(defaultSettings, "", false, nil, nil, newObservabilityConsumerSender, WithRetry(rCfg), WithQueue(qCfg)) require.NoError(t, err) ocs := be.obsrepSender.(*observabilityConsumerSender) @@ -59,7 +60,7 @@ func TestQueuedRetry_StopWhileWaiting(t *testing.T) { func TestQueuedRetry_DoNotPreserveCancellation(t *testing.T) { qCfg := NewDefaultQueueSettings() qCfg.NumConsumers = 1 - rCfg := NewDefaultRetrySettings() + rCfg := configretry.NewDefaultBackOffSettings() be, err := newBaseExporter(defaultSettings, "", false, nil, nil, newObservabilityConsumerSender, WithRetry(rCfg), WithQueue(qCfg)) require.NoError(t, err) ocs := be.obsrepSender.(*observabilityConsumerSender) @@ -102,7 +103,7 @@ func TestQueuedRetryHappyPath(t *testing.T) { t.Cleanup(func() { require.NoError(t, tt.Shutdown(context.Background())) }) qCfg := NewDefaultQueueSettings() - rCfg := NewDefaultRetrySettings() + rCfg := configretry.NewDefaultBackOffSettings() set := exporter.CreateSettings{ID: defaultID, TelemetrySettings: tt.TelemetrySettings, BuildInfo: component.NewDefaultBuildInfo()} be, err := newBaseExporter(set, "", false, nil, nil, newObservabilityConsumerSender, WithRetry(rCfg), WithQueue(qCfg)) require.NoError(t, err) @@ -149,7 +150,7 @@ func TestQueuedRetry_QueueMetricsReported(t *testing.T) { qCfg := NewDefaultQueueSettings() qCfg.NumConsumers = 0 // to make every request go straight to the queue - rCfg := NewDefaultRetrySettings() + rCfg := configretry.NewDefaultBackOffSettings() set := exporter.CreateSettings{ID: defaultID, TelemetrySettings: tt.TelemetrySettings, BuildInfo: component.NewDefaultBuildInfo()} be, err := newBaseExporter(set, "", false, nil, nil, newObservabilityConsumerSender, WithRetry(rCfg), WithQueue(qCfg)) require.NoError(t, err) @@ -174,7 +175,7 @@ func TestQueuedRetry_QueueMetricsReportedUsingOTel(t *testing.T) { qCfg := NewDefaultQueueSettings() qCfg.NumConsumers = 0 // to make every request go straight to the queue - rCfg := NewDefaultRetrySettings() + rCfg := configretry.NewDefaultBackOffSettings() set := exporter.CreateSettings{ID: defaultID, TelemetrySettings: tt.TelemetrySettings, BuildInfo: component.NewDefaultBuildInfo()} be, err := newBaseExporter(set, "", false, nil, nil, newObservabilityConsumerSender, WithRetry(rCfg), WithQueue(qCfg)) require.NoError(t, err) @@ -227,7 +228,7 @@ func TestQueueSettings_Validate(t *testing.T) { func TestQueuedRetry_RequeuingEnabled(t *testing.T) { qCfg := NewDefaultQueueSettings() qCfg.NumConsumers = 1 - rCfg := NewDefaultRetrySettings() + rCfg := configretry.NewDefaultBackOffSettings() rCfg.MaxElapsedTime = time.Nanosecond // we don't want to retry at all, but requeue instead be, err := newBaseExporter(defaultSettings, "", false, nil, nil, newObservabilityConsumerSender, WithRetry(rCfg), WithQueue(qCfg)) require.NoError(t, err) @@ -261,7 +262,7 @@ func TestQueuedRetry_RequeuingDisabled(t *testing.T) { qCfg := NewDefaultQueueSettings() storageID := component.NewIDWithName("file_storage", "storage") qCfg.StorageID = &storageID // enable persistence - rCfg := NewDefaultRetrySettings() + rCfg := configretry.NewDefaultBackOffSettings() rCfg.Enabled = false be, err := newBaseExporter(defaultSettings, "", false, mockRequestMarshaler, mockRequestUnmarshaler(mockR), newObservabilityConsumerSender, WithRetry(rCfg), WithQueue(qCfg)) @@ -291,7 +292,7 @@ func TestQueuedRetry_RequeuingEnabledQueueFull(t *testing.T) { qCfg := NewDefaultQueueSettings() qCfg.NumConsumers = 1 qCfg.QueueSize = 1 - rCfg := NewDefaultRetrySettings() + rCfg := configretry.NewDefaultBackOffSettings() rCfg.MaxElapsedTime = time.Nanosecond // we don't want to retry at all, but requeue instead set := exportertest.NewNopCreateSettings() @@ -356,7 +357,7 @@ func TestQueuedRetryPersistenceEnabled(t *testing.T) { qCfg := NewDefaultQueueSettings() storageID := component.NewIDWithName("file_storage", "storage") qCfg.StorageID = &storageID // enable persistence - rCfg := NewDefaultRetrySettings() + rCfg := configretry.NewDefaultBackOffSettings() set := exporter.CreateSettings{ID: defaultID, TelemetrySettings: tt.TelemetrySettings, BuildInfo: component.NewDefaultBuildInfo()} be, err := newBaseExporter(set, "", false, nil, nil, newObservabilityConsumerSender, WithRetry(rCfg), WithQueue(qCfg)) require.NoError(t, err) @@ -380,7 +381,7 @@ func TestQueuedRetryPersistenceEnabledStorageError(t *testing.T) { qCfg := NewDefaultQueueSettings() storageID := component.NewIDWithName("file_storage", "storage") qCfg.StorageID = &storageID // enable persistence - rCfg := NewDefaultRetrySettings() + rCfg := configretry.NewDefaultBackOffSettings() set := exporter.CreateSettings{ID: defaultID, TelemetrySettings: tt.TelemetrySettings, BuildInfo: component.NewDefaultBuildInfo()} be, err := newBaseExporter(set, "", false, mockRequestMarshaler, mockRequestUnmarshaler(&mockRequest{}), newObservabilityConsumerSender, WithRetry(rCfg), WithQueue(qCfg)) require.NoError(t, err) @@ -400,7 +401,7 @@ func TestQueuedRetryPersistentEnabled_shutdown_dataIsRequeued(t *testing.T) { storageID := component.NewIDWithName("file_storage", "storage") qCfg.StorageID = &storageID // enable persistence to ensure data is re-queued on shutdown - rCfg := NewDefaultRetrySettings() + rCfg := configretry.NewDefaultBackOffSettings() rCfg.InitialInterval = time.Millisecond rCfg.MaxElapsedTime = 0 // retry infinitely so shutdown can be triggered diff --git a/exporter/exporterhelper/retry_sender.go b/exporter/exporterhelper/retry_sender.go index 2e3ff560de34..23d266cb9091 100644 --- a/exporter/exporterhelper/retry_sender.go +++ b/exporter/exporterhelper/retry_sender.go @@ -14,64 +14,17 @@ import ( "go.opentelemetry.io/otel/trace" "go.uber.org/zap" + "go.opentelemetry.io/collector/config/configretry" "go.opentelemetry.io/collector/consumer/consumererror" "go.opentelemetry.io/collector/exporter" "go.opentelemetry.io/collector/internal/obsreportconfig/obsmetrics" ) -// RetrySettings defines configuration for retrying batches in case of export failure. -// The current supported strategy is exponential backoff. -type RetrySettings struct { - // Enabled indicates whether to not retry sending batches in case of export failure. - Enabled bool `mapstructure:"enabled"` - // InitialInterval the time to wait after the first failure before retrying. - InitialInterval time.Duration `mapstructure:"initial_interval"` - // RandomizationFactor is a random factor used to calculate next backoffs - // Randomized interval = RetryInterval * (1 ± RandomizationFactor) - RandomizationFactor float64 `mapstructure:"randomization_factor"` - // Multiplier is the value multiplied by the backoff interval bounds - Multiplier float64 `mapstructure:"multiplier"` - // MaxInterval is the upper bound on backoff interval. Once this value is reached the delay between - // consecutive retries will always be `MaxInterval`. - MaxInterval time.Duration `mapstructure:"max_interval"` - // MaxElapsedTime is the maximum amount of time (including retries) spent trying to send a request/batch. - // Once this value is reached, the data is discarded. - MaxElapsedTime time.Duration `mapstructure:"max_elapsed_time"` -} - -func (cfg *RetrySettings) Validate() error { - if !cfg.Enabled { - return nil - } - if cfg.InitialInterval < 0 { - return errors.New("initial interval must be non-negative") - } - if cfg.RandomizationFactor < 0 || cfg.RandomizationFactor > 1 { - return errors.New("randomization factor must be within [0, 1]") - } - if cfg.Multiplier <= 0 { - return errors.New("multiplier must be positive") - } - if cfg.MaxInterval < 0 { - return errors.New("max interval must be non-negative") - } - if cfg.MaxElapsedTime < 0 { - return errors.New("max elapsed time must be non-negative") - } - return nil -} +// Deprecated: [0.92.0] use configretry.BackOffSettings +type RetrySettings = configretry.BackOffSettings -// NewDefaultRetrySettings returns the default settings for RetrySettings. -func NewDefaultRetrySettings() RetrySettings { - return RetrySettings{ - Enabled: true, - InitialInterval: 5 * time.Second, - RandomizationFactor: backoff.DefaultRandomizationFactor, - Multiplier: backoff.DefaultMultiplier, - MaxInterval: 30 * time.Second, - MaxElapsedTime: 5 * time.Minute, - } -} +// Deprecated: [0.92.0] use configretry.NewDefaultBackOffSettings +var NewDefaultRetrySettings = configretry.NewDefaultBackOffSettings // TODO: Clean this by forcing all exporters to return an internal error type that always include the information about retries. type throttleRetry struct { @@ -98,12 +51,12 @@ func NewThrottleRetry(err error, delay time.Duration) error { type retrySender struct { baseRequestSender traceAttribute attribute.KeyValue - cfg RetrySettings + cfg configretry.BackOffSettings stopCh chan struct{} logger *zap.Logger } -func newRetrySender(config RetrySettings, set exporter.CreateSettings) *retrySender { +func newRetrySender(config configretry.BackOffSettings, set exporter.CreateSettings) *retrySender { return &retrySender{ traceAttribute: attribute.String(obsmetrics.ExporterKey, set.ID.String()), cfg: config, diff --git a/exporter/exporterhelper/retry_sender_test.go b/exporter/exporterhelper/retry_sender_test.go index 9169858c0916..bc688b84fb60 100644 --- a/exporter/exporterhelper/retry_sender_test.go +++ b/exporter/exporterhelper/retry_sender_test.go @@ -20,6 +20,7 @@ import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/component/componenttest" + "go.opentelemetry.io/collector/config/configretry" "go.opentelemetry.io/collector/consumer/consumererror" "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/internal/testdata" @@ -37,7 +38,7 @@ func mockRequestMarshaler(_ Request) ([]byte, error) { func TestQueuedRetry_DropOnPermanentError(t *testing.T) { qCfg := NewDefaultQueueSettings() - rCfg := NewDefaultRetrySettings() + rCfg := configretry.NewDefaultBackOffSettings() mockR := newMockRequest(2, consumererror.NewPermanent(errors.New("bad data"))) be, err := newBaseExporter(defaultSettings, "", false, nil, nil, newObservabilityConsumerSender, WithRetry(rCfg), WithQueue(qCfg)) require.NoError(t, err) @@ -60,7 +61,7 @@ func TestQueuedRetry_DropOnPermanentError(t *testing.T) { func TestQueuedRetry_DropOnNoRetry(t *testing.T) { qCfg := NewDefaultQueueSettings() - rCfg := NewDefaultRetrySettings() + rCfg := configretry.NewDefaultBackOffSettings() rCfg.Enabled = false be, err := newBaseExporter(defaultSettings, "", false, mockRequestMarshaler, mockRequestUnmarshaler(newMockRequest(2, errors.New("transient error"))), @@ -87,7 +88,7 @@ func TestQueuedRetry_DropOnNoRetry(t *testing.T) { func TestQueuedRetry_OnError(t *testing.T) { qCfg := NewDefaultQueueSettings() qCfg.NumConsumers = 1 - rCfg := NewDefaultRetrySettings() + rCfg := configretry.NewDefaultBackOffSettings() rCfg.InitialInterval = 0 be, err := newBaseExporter(defaultSettings, "", false, nil, nil, newObservabilityConsumerSender, WithRetry(rCfg), WithQueue(qCfg)) require.NoError(t, err) @@ -114,7 +115,7 @@ func TestQueuedRetry_OnError(t *testing.T) { func TestQueuedRetry_MaxElapsedTime(t *testing.T) { qCfg := NewDefaultQueueSettings() qCfg.NumConsumers = 1 - rCfg := NewDefaultRetrySettings() + rCfg := configretry.NewDefaultBackOffSettings() rCfg.InitialInterval = time.Millisecond rCfg.MaxElapsedTime = 100 * time.Millisecond be, err := newBaseExporter(defaultSettings, "", false, nil, nil, newObservabilityConsumerSender, WithRetry(rCfg), WithQueue(qCfg)) @@ -161,7 +162,7 @@ func (e wrappedError) Unwrap() error { func TestQueuedRetry_ThrottleError(t *testing.T) { qCfg := NewDefaultQueueSettings() qCfg.NumConsumers = 1 - rCfg := NewDefaultRetrySettings() + rCfg := configretry.NewDefaultBackOffSettings() rCfg.InitialInterval = 10 * time.Millisecond be, err := newBaseExporter(defaultSettings, "", false, nil, nil, newObservabilityConsumerSender, WithRetry(rCfg), WithQueue(qCfg)) require.NoError(t, err) @@ -193,7 +194,7 @@ func TestQueuedRetry_RetryOnError(t *testing.T) { qCfg := NewDefaultQueueSettings() qCfg.NumConsumers = 1 qCfg.QueueSize = 1 - rCfg := NewDefaultRetrySettings() + rCfg := configretry.NewDefaultBackOffSettings() rCfg.InitialInterval = 0 be, err := newBaseExporter(defaultSettings, "", false, nil, nil, newObservabilityConsumerSender, WithRetry(rCfg), WithQueue(qCfg)) require.NoError(t, err) @@ -218,7 +219,7 @@ func TestQueuedRetry_RetryOnError(t *testing.T) { } func TestQueueRetryWithNoQueue(t *testing.T) { - rCfg := NewDefaultRetrySettings() + rCfg := configretry.NewDefaultBackOffSettings() rCfg.MaxElapsedTime = time.Nanosecond // fail fast be, err := newBaseExporter(exportertest.NewNopCreateSettings(), component.DataTypeLogs, false, nil, nil, newObservabilityConsumerSender, WithRetry(rCfg)) require.NoError(t, err) @@ -236,7 +237,7 @@ func TestQueueRetryWithNoQueue(t *testing.T) { } func TestQueueRetryWithDisabledRetires(t *testing.T) { - rCfg := NewDefaultRetrySettings() + rCfg := configretry.NewDefaultBackOffSettings() rCfg.Enabled = false be, err := newBaseExporter(exportertest.NewNopCreateSettings(), component.DataTypeLogs, false, nil, nil, newObservabilityConsumerSender, WithRetry(rCfg)) require.IsType(t, &errorLoggingRequestSender{}, be.retrySender) @@ -404,66 +405,3 @@ func tagsMatchLabelKeys(tags []tag.Tag, keys []metricdata.LabelKey, labels []met } return true } - -func TestNewDefaultRetrySettings(t *testing.T) { - cfg := NewDefaultRetrySettings() - assert.NoError(t, cfg.Validate()) - assert.Equal(t, - RetrySettings{ - Enabled: true, - InitialInterval: 5 * time.Second, - RandomizationFactor: 0.5, - Multiplier: 1.5, - MaxInterval: 30 * time.Second, - MaxElapsedTime: 5 * time.Minute, - }, cfg) -} - -func TestInvalidInitialInterval(t *testing.T) { - cfg := NewDefaultRetrySettings() - assert.NoError(t, cfg.Validate()) - cfg.InitialInterval = -1 - assert.Error(t, cfg.Validate()) -} - -func TestInvalidRandomizationFactor(t *testing.T) { - cfg := NewDefaultRetrySettings() - assert.NoError(t, cfg.Validate()) - cfg.RandomizationFactor = -1 - assert.Error(t, cfg.Validate()) - cfg.RandomizationFactor = 2 - assert.Error(t, cfg.Validate()) -} - -func TestInvalidMultiplier(t *testing.T) { - cfg := NewDefaultRetrySettings() - assert.NoError(t, cfg.Validate()) - cfg.Multiplier = 0 - assert.Error(t, cfg.Validate()) -} - -func TestInvalidMaxInterval(t *testing.T) { - cfg := NewDefaultRetrySettings() - assert.NoError(t, cfg.Validate()) - cfg.MaxInterval = -1 - assert.Error(t, cfg.Validate()) -} - -func TestInvalidMaxElapsedTime(t *testing.T) { - cfg := NewDefaultRetrySettings() - assert.NoError(t, cfg.Validate()) - cfg.MaxElapsedTime = -1 - assert.Error(t, cfg.Validate()) -} - -func TestDisabledWithInvalidValues(t *testing.T) { - cfg := RetrySettings{ - Enabled: false, - InitialInterval: -1, - RandomizationFactor: -1, - Multiplier: 0, - MaxInterval: -1, - MaxElapsedTime: -1, - } - assert.NoError(t, cfg.Validate()) -} diff --git a/exporter/exporterhelper/traces_test.go b/exporter/exporterhelper/traces_test.go index 1209f8da2ba5..b8a80321d14f 100644 --- a/exporter/exporterhelper/traces_test.go +++ b/exporter/exporterhelper/traces_test.go @@ -20,6 +20,7 @@ import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/component/componenttest" + "go.opentelemetry.io/collector/config/configretry" "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/consumer/consumererror" "go.opentelemetry.io/collector/consumer/consumertest" @@ -157,7 +158,7 @@ func TestTracesExporter_WithPersistentQueue(t *testing.T) { qCfg := NewDefaultQueueSettings() storageID := component.NewIDWithName("file_storage", "storage") qCfg.StorageID = &storageID - rCfg := NewDefaultRetrySettings() + rCfg := configretry.NewDefaultBackOffSettings() ts := consumertest.TracesSink{} set := exportertest.NewNopCreateSettings() set.ID = component.NewIDWithName("test_traces", "with_persistent_queue") @@ -236,7 +237,7 @@ func TestTracesExporter_WithRecordEnqueueFailedMetrics(t *testing.T) { require.NoError(t, err) t.Cleanup(func() { require.NoError(t, tt.Shutdown(context.Background())) }) - rCfg := NewDefaultRetrySettings() + rCfg := configretry.NewDefaultBackOffSettings() qCfg := NewDefaultQueueSettings() qCfg.NumConsumers = 1 qCfg.QueueSize = 2 diff --git a/exporter/exportertest/contract_checker_test.go b/exporter/exportertest/contract_checker_test.go index 2ea2ac9be352..882620f4450f 100644 --- a/exporter/exportertest/contract_checker_test.go +++ b/exporter/exportertest/contract_checker_test.go @@ -9,6 +9,7 @@ import ( "time" "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/config/configretry" "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/exporter" "go.opentelemetry.io/collector/exporter/exporterhelper" @@ -16,8 +17,8 @@ import ( ) // retryConfig is a configuration to quickly retry failed exports. -var retryConfig = func() exporterhelper.RetrySettings { - c := exporterhelper.NewDefaultRetrySettings() +var retryConfig = func() configretry.BackOffSettings { + c := configretry.NewDefaultBackOffSettings() c.InitialInterval = time.Millisecond return c }() diff --git a/exporter/go.mod b/exporter/go.mod index 3ca2071e7318..697228bef1d3 100644 --- a/exporter/go.mod +++ b/exporter/go.mod @@ -8,6 +8,7 @@ require ( go.opencensus.io v0.24.0 go.opentelemetry.io/collector v0.91.0 go.opentelemetry.io/collector/component v0.91.0 + go.opentelemetry.io/collector/config/configretry v0.91.0 go.opentelemetry.io/collector/config/configtelemetry v0.91.0 go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/extension v0.91.0 @@ -84,6 +85,6 @@ replace go.opentelemetry.io/collector/receiver => ../receiver retract v0.76.0 // Depends on retracted pdata v1.0.0-rc10 module -replace go.opentelemetry.io/collector/connector => ../connector +replace go.opentelemetry.io/collector/config/configretry => ../config/configretry replace go.opentelemetry.io/collector/config/configtelemetry => ../config/configtelemetry diff --git a/exporter/loggingexporter/go.mod b/exporter/loggingexporter/go.mod index 8149aa882c59..c53273589bd5 100644 --- a/exporter/loggingexporter/go.mod +++ b/exporter/loggingexporter/go.mod @@ -30,6 +30,7 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect go.opencensus.io v0.24.0 // indirect go.opentelemetry.io/collector v0.91.0 // indirect + go.opentelemetry.io/collector/config/configretry v0.91.0 // indirect go.opentelemetry.io/collector/consumer v0.91.0 // indirect go.opentelemetry.io/collector/extension v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect @@ -76,3 +77,5 @@ retract ( replace go.opentelemetry.io/collector/connector => ../../connector replace go.opentelemetry.io/collector/config/configtelemetry => ../../config/configtelemetry + +replace go.opentelemetry.io/collector/config/configretry => ../../config/configretry diff --git a/exporter/otlpexporter/config.go b/exporter/otlpexporter/config.go index d276f6e7c872..40f5f8fe5550 100644 --- a/exporter/otlpexporter/config.go +++ b/exporter/otlpexporter/config.go @@ -5,6 +5,7 @@ package otlpexporter // import "go.opentelemetry.io/collector/exporter/otlpexpor import ( "fmt" + "go.opentelemetry.io/collector/config/configretry" "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/config/configgrpc" @@ -15,7 +16,7 @@ import ( type Config struct { exporterhelper.TimeoutSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct. exporterhelper.QueueSettings `mapstructure:"sending_queue"` - exporterhelper.RetrySettings `mapstructure:"retry_on_failure"` + RetrySettings configretry.BackOffSettings `mapstructure:"retry_on_failure"` configgrpc.GRPCClientSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct. } diff --git a/exporter/otlpexporter/config_test.go b/exporter/otlpexporter/config_test.go index ebc1789a41e0..d0dc67c7d8c8 100644 --- a/exporter/otlpexporter/config_test.go +++ b/exporter/otlpexporter/config_test.go @@ -4,6 +4,7 @@ package otlpexporter import ( + "go.opentelemetry.io/collector/config/configretry" "path/filepath" "testing" "time" @@ -39,7 +40,7 @@ func TestUnmarshalConfig(t *testing.T) { TimeoutSettings: exporterhelper.TimeoutSettings{ Timeout: 10 * time.Second, }, - RetrySettings: exporterhelper.RetrySettings{ + RetrySettings: configretry.BackOffSettings{ Enabled: true, InitialInterval: 10 * time.Second, RandomizationFactor: 0.7, diff --git a/exporter/otlpexporter/consume_contract_test.go b/exporter/otlpexporter/consume_contract_test.go index 6dd0dcb6547b..35defe3f33ba 100644 --- a/exporter/otlpexporter/consume_contract_test.go +++ b/exporter/otlpexporter/consume_contract_test.go @@ -9,6 +9,7 @@ import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/config/configgrpc" + "go.opentelemetry.io/collector/config/configretry" "go.opentelemetry.io/collector/config/configtls" "go.opentelemetry.io/collector/exporter/exporterhelper" "go.opentelemetry.io/collector/exporter/exportertest" @@ -17,7 +18,7 @@ import ( ) func testExporterConfig(endpoint string) component.Config { - retryConfig := exporterhelper.NewDefaultRetrySettings() + retryConfig := configretry.NewDefaultBackOffSettings() retryConfig.InitialInterval = time.Millisecond // interval is short for the test purposes return &Config{ QueueSettings: exporterhelper.QueueSettings{Enabled: false}, diff --git a/exporter/otlpexporter/factory.go b/exporter/otlpexporter/factory.go index 3980216331a8..88035d27039c 100644 --- a/exporter/otlpexporter/factory.go +++ b/exporter/otlpexporter/factory.go @@ -10,6 +10,7 @@ import ( "go.opentelemetry.io/collector/config/configcompression" "go.opentelemetry.io/collector/config/configgrpc" "go.opentelemetry.io/collector/config/configopaque" + "go.opentelemetry.io/collector/config/configretry" "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/exporter" "go.opentelemetry.io/collector/exporter/exporterhelper" @@ -34,7 +35,7 @@ func NewFactory() exporter.Factory { func createDefaultConfig() component.Config { return &Config{ TimeoutSettings: exporterhelper.NewDefaultTimeoutSettings(), - RetrySettings: exporterhelper.NewDefaultRetrySettings(), + RetrySettings: configretry.NewDefaultBackOffSettings(), QueueSettings: exporterhelper.NewDefaultQueueSettings(), GRPCClientSettings: configgrpc.GRPCClientSettings{ Headers: map[string]configopaque.String{}, diff --git a/exporter/otlpexporter/factory_test.go b/exporter/otlpexporter/factory_test.go index 4ebb0e283ba7..585ddd4a4f14 100644 --- a/exporter/otlpexporter/factory_test.go +++ b/exporter/otlpexporter/factory_test.go @@ -16,6 +16,7 @@ import ( "go.opentelemetry.io/collector/config/configcompression" "go.opentelemetry.io/collector/config/configgrpc" "go.opentelemetry.io/collector/config/configopaque" + "go.opentelemetry.io/collector/config/configretry" "go.opentelemetry.io/collector/config/configtls" "go.opentelemetry.io/collector/exporter/exporterhelper" "go.opentelemetry.io/collector/exporter/exportertest" @@ -29,7 +30,7 @@ func TestCreateDefaultConfig(t *testing.T) { assert.NoError(t, componenttest.CheckConfigStruct(cfg)) ocfg, ok := factory.CreateDefaultConfig().(*Config) assert.True(t, ok) - assert.Equal(t, ocfg.RetrySettings, exporterhelper.NewDefaultRetrySettings()) + assert.Equal(t, ocfg.RetrySettings, configretry.NewDefaultBackOffSettings()) assert.Equal(t, ocfg.QueueSettings, exporterhelper.NewDefaultQueueSettings()) assert.Equal(t, ocfg.TimeoutSettings, exporterhelper.NewDefaultTimeoutSettings()) assert.Equal(t, ocfg.Compression, configcompression.Gzip) diff --git a/exporter/otlpexporter/go.mod b/exporter/otlpexporter/go.mod index 3b5d4f1408b5..910ab63cd907 100644 --- a/exporter/otlpexporter/go.mod +++ b/exporter/otlpexporter/go.mod @@ -10,6 +10,7 @@ require ( go.opentelemetry.io/collector/config/configcompression v0.91.0 go.opentelemetry.io/collector/config/configgrpc v0.91.0 go.opentelemetry.io/collector/config/configopaque v0.91.0 + go.opentelemetry.io/collector/config/configretry v0.91.0 go.opentelemetry.io/collector/config/configtls v0.91.0 go.opentelemetry.io/collector/confmap v0.91.0 go.opentelemetry.io/collector/consumer v0.91.0 @@ -121,3 +122,5 @@ replace go.opentelemetry.io/collector/config/confighttp => ../../config/confight replace go.opentelemetry.io/collector/receiver/otlpreceiver => ../../receiver/otlpreceiver replace go.opentelemetry.io/collector/semconv => ../../semconv + +replace go.opentelemetry.io/collector/config/configretry => ../../config/configretry diff --git a/exporter/otlphttpexporter/config.go b/exporter/otlphttpexporter/config.go index 692f7e0124b5..84fe78505d92 100644 --- a/exporter/otlphttpexporter/config.go +++ b/exporter/otlphttpexporter/config.go @@ -5,6 +5,7 @@ package otlphttpexporter // import "go.opentelemetry.io/collector/exporter/otlph import ( "errors" + "go.opentelemetry.io/collector/config/configretry" "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/config/confighttp" @@ -15,7 +16,7 @@ import ( type Config struct { confighttp.HTTPClientSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct. exporterhelper.QueueSettings `mapstructure:"sending_queue"` - exporterhelper.RetrySettings `mapstructure:"retry_on_failure"` + RetrySettings configretry.BackOffSettings `mapstructure:"retry_on_failure"` // The URL to send traces to. If omitted the Endpoint + "/v1/traces" will be used. TracesEndpoint string `mapstructure:"traces_endpoint"` diff --git a/exporter/otlphttpexporter/config_test.go b/exporter/otlphttpexporter/config_test.go index 35b2d15a1603..6bf2f7177e16 100644 --- a/exporter/otlphttpexporter/config_test.go +++ b/exporter/otlphttpexporter/config_test.go @@ -4,6 +4,7 @@ package otlphttpexporter import ( + "go.opentelemetry.io/collector/config/configretry" "path/filepath" "testing" "time" @@ -37,7 +38,7 @@ func TestUnmarshalConfig(t *testing.T) { assert.NoError(t, component.UnmarshalConfig(cm, cfg)) assert.Equal(t, &Config{ - RetrySettings: exporterhelper.RetrySettings{ + RetrySettings: configretry.BackOffSettings{ Enabled: true, InitialInterval: 10 * time.Second, RandomizationFactor: 0.7, diff --git a/exporter/otlphttpexporter/factory.go b/exporter/otlphttpexporter/factory.go index 4bdbcdf40fda..b66150e3fc53 100644 --- a/exporter/otlphttpexporter/factory.go +++ b/exporter/otlphttpexporter/factory.go @@ -14,6 +14,7 @@ import ( "go.opentelemetry.io/collector/config/configcompression" "go.opentelemetry.io/collector/config/confighttp" "go.opentelemetry.io/collector/config/configopaque" + "go.opentelemetry.io/collector/config/configretry" "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/exporter" "go.opentelemetry.io/collector/exporter/exporterhelper" @@ -37,7 +38,7 @@ func NewFactory() exporter.Factory { func createDefaultConfig() component.Config { return &Config{ - RetrySettings: exporterhelper.NewDefaultRetrySettings(), + RetrySettings: configretry.NewDefaultBackOffSettings(), QueueSettings: exporterhelper.NewDefaultQueueSettings(), HTTPClientSettings: confighttp.HTTPClientSettings{ Endpoint: "", diff --git a/exporter/otlphttpexporter/go.mod b/exporter/otlphttpexporter/go.mod index 62fca98fa4c2..5726a96a37fe 100644 --- a/exporter/otlphttpexporter/go.mod +++ b/exporter/otlphttpexporter/go.mod @@ -9,6 +9,7 @@ require ( go.opentelemetry.io/collector/config/configcompression v0.91.0 go.opentelemetry.io/collector/config/confighttp v0.91.0 go.opentelemetry.io/collector/config/configopaque v0.91.0 + go.opentelemetry.io/collector/config/configretry v0.91.0 go.opentelemetry.io/collector/config/configtls v0.91.0 go.opentelemetry.io/collector/confmap v0.91.0 go.opentelemetry.io/collector/consumer v0.91.0 @@ -121,3 +122,5 @@ retract ( v0.76.0 // Depends on retracted pdata v1.0.0-rc10 module, use v0.76.1 v0.69.0 // Release failed, use v0.69.1 ) + +replace go.opentelemetry.io/collector/config/configretry => ../../config/configretry diff --git a/extension/ballastextension/go.mod b/extension/ballastextension/go.mod index 692834460918..47ab71c482cd 100644 --- a/extension/ballastextension/go.mod +++ b/extension/ballastextension/go.mod @@ -74,3 +74,5 @@ replace go.opentelemetry.io/collector/processor => ../../processor replace go.opentelemetry.io/collector/connector => ../../connector replace go.opentelemetry.io/collector/config/configtelemetry => ../../config/configtelemetry + +replace go.opentelemetry.io/collector/config/configretry => ../../config/configretry diff --git a/extension/zpagesextension/go.mod b/extension/zpagesextension/go.mod index a1aa571d93da..a07a18c5b1fd 100644 --- a/extension/zpagesextension/go.mod +++ b/extension/zpagesextension/go.mod @@ -76,3 +76,5 @@ retract ( replace go.opentelemetry.io/collector/connector => ../../connector replace go.opentelemetry.io/collector/config/configtelemetry => ../../config/configtelemetry + +replace go.opentelemetry.io/collector/config/configretry => ../../config/configretry diff --git a/go.mod b/go.mod index 4d5ed16051a2..d516ccea4680 100644 --- a/go.mod +++ b/go.mod @@ -59,6 +59,7 @@ require ( github.com/tklauser/go-sysconf v0.3.12 // indirect github.com/tklauser/numcpus v0.6.1 // indirect github.com/yusufpapurcu/wmi v1.2.3 // indirect + go.opentelemetry.io/collector/config/configretry v0.91.0 // indirect go.opentelemetry.io/collector/confmap v0.91.0 // indirect go.opentelemetry.io/collector/extension v0.91.0 // indirect go.opentelemetry.io/otel/metric v1.21.0 // indirect @@ -97,6 +98,8 @@ replace go.opentelemetry.io/collector/processor => ./processor replace go.opentelemetry.io/collector/receiver => ./receiver +replace go.opentelemetry.io/collector/config/configretry => ./config/configretry + retract ( v0.76.0 // Depends on retracted pdata v1.0.0-rc10 module, use v0.76.1 v0.69.0 // Release failed, use v0.69.1 diff --git a/otelcol/go.mod b/otelcol/go.mod index 8adb62d4a7a4..ce55da5a03e6 100644 --- a/otelcol/go.mod +++ b/otelcol/go.mod @@ -126,3 +126,5 @@ replace go.opentelemetry.io/collector/receiver => ../receiver replace go.opentelemetry.io/collector/featuregate => ../featuregate replace go.opentelemetry.io/collector/config/confignet => ../config/confignet + +replace go.opentelemetry.io/collector/config/configretry => ../config/configretry diff --git a/processor/batchprocessor/go.mod b/processor/batchprocessor/go.mod index f4dd3f16cc98..d38ac49e8d5d 100644 --- a/processor/batchprocessor/go.mod +++ b/processor/batchprocessor/go.mod @@ -90,3 +90,5 @@ retract ( replace go.opentelemetry.io/collector/connector => ../../connector replace go.opentelemetry.io/collector/config/configtelemetry => ../../config/configtelemetry + +replace go.opentelemetry.io/collector/config/configretry => ../../config/configretry diff --git a/processor/go.mod b/processor/go.mod index 5fbce367b1c8..fcc01b4327d7 100644 --- a/processor/go.mod +++ b/processor/go.mod @@ -82,3 +82,5 @@ replace go.opentelemetry.io/collector/receiver => ../receiver replace go.opentelemetry.io/collector/connector => ../connector replace go.opentelemetry.io/collector/config/configtelemetry => ../config/configtelemetry + +replace go.opentelemetry.io/collector/config/configretry => ../config/configretry diff --git a/processor/memorylimiterprocessor/go.mod b/processor/memorylimiterprocessor/go.mod index 62b7249a5022..5bba29e4d73d 100644 --- a/processor/memorylimiterprocessor/go.mod +++ b/processor/memorylimiterprocessor/go.mod @@ -79,3 +79,5 @@ retract ( replace go.opentelemetry.io/collector/connector => ../../connector replace go.opentelemetry.io/collector/config/configtelemetry => ../../config/configtelemetry + +replace go.opentelemetry.io/collector/config/configretry => ../../config/configretry diff --git a/receiver/go.mod b/receiver/go.mod index 7a93d8099899..3a4b0285dbd3 100644 --- a/receiver/go.mod +++ b/receiver/go.mod @@ -84,3 +84,5 @@ retract v0.76.0 // Depends on retracted pdata v1.0.0-rc10 module replace go.opentelemetry.io/collector/connector => ../connector replace go.opentelemetry.io/collector/config/configtelemetry => ../config/configtelemetry + +replace go.opentelemetry.io/collector/config/configretry => ../config/configretry diff --git a/receiver/otlpreceiver/go.mod b/receiver/otlpreceiver/go.mod index 007ade23b2c6..7d03f39cfde3 100644 --- a/receiver/otlpreceiver/go.mod +++ b/receiver/otlpreceiver/go.mod @@ -131,3 +131,5 @@ retract ( v0.76.0 // Depends on retracted pdata v1.0.0-rc10 module, use v0.76.1 v0.69.0 // Release failed, use v0.69.1 ) + +replace go.opentelemetry.io/collector/config/configretry => ../../config/configretry diff --git a/service/go.mod b/service/go.mod index e8a7eafca541..652919f769e1 100644 --- a/service/go.mod +++ b/service/go.mod @@ -123,3 +123,5 @@ replace go.opentelemetry.io/collector/receiver => ../receiver replace go.opentelemetry.io/collector/featuregate => ../featuregate replace go.opentelemetry.io/collector/config/confignet => ../config/confignet + +replace go.opentelemetry.io/collector/config/configretry => ../config/configretry diff --git a/versions.yaml b/versions.yaml index 73dcb57025c4..ddf51b5fbe79 100644 --- a/versions.yaml +++ b/versions.yaml @@ -20,6 +20,7 @@ module-sets: - go.opentelemetry.io/collector/config/confighttp - go.opentelemetry.io/collector/config/confignet - go.opentelemetry.io/collector/config/configopaque + - go.opentelemetry.io/collector/config/configretry - go.opentelemetry.io/collector/config/configtelemetry - go.opentelemetry.io/collector/config/configtls - go.opentelemetry.io/collector/config/internal