From e9e0dd11835b760954a71d52a584b20752c8c61c 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.BackOffConfig Signed-off-by: Bogdan Drutu --- .chloggen/deprecateretry.yaml | 20 +++++ .chloggen/deprecateretry_dep.yaml | 13 +++ Makefile | 2 + cmd/builder/test/core.builder.yaml | 1 + cmd/otelcorecol/builder-config.yaml | 1 + cmd/otelcorecol/go.mod | 3 + config/configgrpc/go.mod | 4 + config/confighttp/go.mod | 2 + config/configretry/Makefile | 1 + config/configretry/backoff.go | 65 +++++++++++++++ config/configretry/backoff_test.go | 74 +++++++++++++++++ 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 | 17 ++-- 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 | 5 ++ exporter/loggingexporter/go.mod | 3 + exporter/otlpexporter/config.go | 18 +---- exporter/otlpexporter/config_test.go | 5 +- .../otlpexporter/consume_contract_test.go | 7 +- exporter/otlpexporter/factory.go | 17 ++-- exporter/otlpexporter/factory_test.go | 5 +- exporter/otlpexporter/go.mod | 3 + exporter/otlpexporter/otlp_test.go | 10 +-- exporter/otlphttpexporter/config.go | 7 +- exporter/otlphttpexporter/config_test.go | 5 +- exporter/otlphttpexporter/factory.go | 17 ++-- exporter/otlphttpexporter/factory_test.go | 10 +-- exporter/otlphttpexporter/go.mod | 3 + exporter/otlphttpexporter/otlp_test.go | 6 +- 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 + 52 files changed, 370 insertions(+), 202 deletions(-) create mode 100755 .chloggen/deprecateretry.yaml create mode 100755 .chloggen/deprecateretry_dep.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 00000000000..92399ed9910 --- /dev/null +++ b/.chloggen/deprecateretry.yaml @@ -0,0 +1,20 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: 'breaking' + +# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver) +component: otlpexporter + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Change Config members names to use Config suffix. + +# One or more tracking issues or pull requests related to the change +issues: [9091] + +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [api] \ No newline at end of file diff --git a/.chloggen/deprecateretry_dep.yaml b/.chloggen/deprecateretry_dep.yaml new file mode 100755 index 00000000000..84e30e22c38 --- /dev/null +++ b/.chloggen/deprecateretry_dep.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.BackOffConfig" + +# One or more tracking issues or pull requests related to the change +issues: [9091] diff --git a/Makefile b/Makefile index 014988194d7..dc7884c89bb 100644 --- a/Makefile +++ b/Makefile @@ -249,6 +249,7 @@ check-contrib: @$(MAKE) -C $(CONTRIB_PATH) for-all CMD="$(GOCMD) mod edit -replace go.opentelemetry.io/collector/config/confighttp=$(CURDIR)/config/confighttp" @$(MAKE) -C $(CONTRIB_PATH) for-all CMD="$(GOCMD) mod edit -replace go.opentelemetry.io/collector/config/confignet=$(CURDIR)/config/confignet" @$(MAKE) -C $(CONTRIB_PATH) for-all CMD="$(GOCMD) mod edit -replace go.opentelemetry.io/collector/config/configopaque=$(CURDIR)/config/configopaque" + @$(MAKE) -C $(CONTRIB_PATH) for-all CMD="$(GOCMD) mod edit -replace go.opentelemetry.io/collector/config/configretry=$(CURDIR)/config/configretry" @$(MAKE) -C $(CONTRIB_PATH) for-all CMD="$(GOCMD) mod edit -replace go.opentelemetry.io/collector/config/configtelemetry=$(CURDIR)/config/configtelemetry" @$(MAKE) -C $(CONTRIB_PATH) for-all CMD="$(GOCMD) mod edit -replace go.opentelemetry.io/collector/config/configtls=$(CURDIR)/config/configtls" @$(MAKE) -C $(CONTRIB_PATH) for-all CMD="$(GOCMD) mod edit -replace go.opentelemetry.io/collector/config/internal=$(CURDIR)/config/internal" @@ -292,6 +293,7 @@ restore-contrib: @$(MAKE) -C $(CONTRIB_PATH) for-all CMD="$(GOCMD) mod edit -dropreplace go.opentelemetry.io/collector/config/confighttp" @$(MAKE) -C $(CONTRIB_PATH) for-all CMD="$(GOCMD) mod edit -dropreplace go.opentelemetry.io/collector/config/confignet" @$(MAKE) -C $(CONTRIB_PATH) for-all CMD="$(GOCMD) mod edit -dropreplace go.opentelemetry.io/collector/config/configopaque" + @$(MAKE) -C $(CONTRIB_PATH) for-all CMD="$(GOCMD) mod edit -dropreplace go.opentelemetry.io/collector/config/configretry" @$(MAKE) -C $(CONTRIB_PATH) for-all CMD="$(GOCMD) mod edit -dropreplace go.opentelemetry.io/collector/config/configtelemetry" @$(MAKE) -C $(CONTRIB_PATH) for-all CMD="$(GOCMD) mod edit -dropreplace go.opentelemetry.io/collector/config/configtls" @$(MAKE) -C $(CONTRIB_PATH) for-all CMD="$(GOCMD) mod edit -dropreplace go.opentelemetry.io/collector/config/internal" diff --git a/cmd/builder/test/core.builder.yaml b/cmd/builder/test/core.builder.yaml index 4f792b2ee82..34017f6fe41 100644 --- a/cmd/builder/test/core.builder.yaml +++ b/cmd/builder/test/core.builder.yaml @@ -26,6 +26,7 @@ replaces: - go.opentelemetry.io/collector/config/confighttp => ${WORKSPACE_DIR}/config/confighttp - go.opentelemetry.io/collector/config/confignet => ${WORKSPACE_DIR}/config/confignet - go.opentelemetry.io/collector/config/configopaque => ${WORKSPACE_DIR}/config/configopaque + - go.opentelemetry.io/collector/config/configretry => ${WORKSPACE_DIR}/config/configretry - go.opentelemetry.io/collector/config/configtelemetry => ${WORKSPACE_DIR}/config/configtelemetry - go.opentelemetry.io/collector/config/configtls => ${WORKSPACE_DIR}/config/configtls - go.opentelemetry.io/collector/config/internal => ${WORKSPACE_DIR}/config/internal diff --git a/cmd/otelcorecol/builder-config.yaml b/cmd/otelcorecol/builder-config.yaml index 60414f8d0d7..4da64de2440 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 3b2d80884fc..688e38221e7 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 @@ -145,6 +146,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/config/configgrpc/go.mod b/config/configgrpc/go.mod index fd7dc3d068a..275c345dee2 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 @@ -109,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 7ab2ba6f887..5a0690bc617 100644 --- a/config/confighttp/go.mod +++ b/config/confighttp/go.mod @@ -86,3 +86,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 00000000000..ded7a36092d --- /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 00000000000..c3ffc68fe8d --- /dev/null +++ b/config/configretry/backoff.go @@ -0,0 +1,65 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package configretry // import "go.opentelemetry.io/collector/config/configretry" + +import ( + "errors" + "time" + + "github.com/cenkalti/backoff/v4" +) + +// NewDefaultBackOffConfig returns the default settings for RetryConfig. +func NewDefaultBackOffConfig() BackOffConfig { + return BackOffConfig{ + Enabled: true, + InitialInterval: 5 * time.Second, + RandomizationFactor: backoff.DefaultRandomizationFactor, + Multiplier: backoff.DefaultMultiplier, + MaxInterval: 30 * time.Second, + MaxElapsedTime: 5 * time.Minute, + } +} + +// BackOffConfig defines configuration for retrying batches in case of export failure. +// The current supported strategy is exponential backoff. +type BackOffConfig 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. If set to 0, the retries are never stopped. + MaxElapsedTime time.Duration `mapstructure:"max_elapsed_time"` +} + +func (bs *BackOffConfig) 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 00000000000..8c9bf7f41c3 --- /dev/null +++ b/config/configretry/backoff_test.go @@ -0,0 +1,74 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package configretry + +import ( + "testing" + "time" + + "github.com/stretchr/testify/assert" +) + +func TestNewDefaultBackOffSettings(t *testing.T) { + cfg := NewDefaultBackOffConfig() + assert.NoError(t, cfg.Validate()) + assert.Equal(t, + BackOffConfig{ + 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 := NewDefaultBackOffConfig() + assert.NoError(t, cfg.Validate()) + cfg.InitialInterval = -1 + assert.Error(t, cfg.Validate()) +} + +func TestInvalidRandomizationFactor(t *testing.T) { + cfg := NewDefaultBackOffConfig() + 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 := NewDefaultBackOffConfig() + assert.NoError(t, cfg.Validate()) + cfg.Multiplier = 0 + assert.Error(t, cfg.Validate()) +} + +func TestInvalidMaxInterval(t *testing.T) { + cfg := NewDefaultBackOffConfig() + assert.NoError(t, cfg.Validate()) + cfg.MaxInterval = -1 + assert.Error(t, cfg.Validate()) +} + +func TestInvalidMaxElapsedTime(t *testing.T) { + cfg := NewDefaultBackOffConfig() + assert.NoError(t, cfg.Validate()) + cfg.MaxElapsedTime = -1 + assert.Error(t, cfg.Validate()) +} + +func TestDisabledWithInvalidValues(t *testing.T) { + cfg := BackOffConfig{ + 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 00000000000..054a91e92f6 --- /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 00000000000..f782e6a3ba9 --- /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 154cd39c3bc..e9f41e492a5 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 66d28697fac..1758e26bad1 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 e7b0219260b..4a8e16bf89d 100644 --- a/consumer/go.mod +++ b/consumer/go.mod @@ -51,3 +51,5 @@ retract ( ) 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 747eb68b28c..0462ca61d7d 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 @@ -68,3 +69,5 @@ replace go.opentelemetry.io/collector/extension => ../../extension 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 bc840d754c6..2c5a4e96692 100644 --- a/exporter/exporterhelper/common.go +++ b/exporter/exporterhelper/common.go @@ -10,6 +10,7 @@ import ( "go.uber.org/zap" "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/config/configretry" "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/exporter" ) @@ -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.BackOffConfig for an exporter. +// The default configretry.BackOffConfig is to disable retries. +func WithRetry(config configretry.BackOffConfig) 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 0e74e095147..13568ffb49f 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.NewDefaultBackOffConfig())) 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.NewDefaultBackOffConfig()), 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.NewDefaultBackOffConfig() 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 feaa9948323..23878613bbf 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.NewDefaultBackOffConfig() 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.NewDefaultBackOffConfig() qCfg := NewDefaultQueueSettings() qCfg.NumConsumers = 1 qCfg.QueueSize = 2 diff --git a/exporter/exporterhelper/metrics_test.go b/exporter/exporterhelper/metrics_test.go index 57a01a30243..eef5edf6b62 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.NewDefaultBackOffConfig() 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.NewDefaultBackOffConfig() 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 cdac341ec1f..fe0633a605d 100644 --- a/exporter/exporterhelper/queue_sender_test.go +++ b/exporter/exporterhelper/queue_sender_test.go @@ -14,6 +14,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" @@ -25,7 +26,7 @@ import ( func TestQueuedRetry_StopWhileWaiting(t *testing.T) { qCfg := NewDefaultQueueSettings() qCfg.NumConsumers = 1 - rCfg := NewDefaultRetrySettings() + rCfg := configretry.NewDefaultBackOffConfig() be, err := newBaseExporter(defaultSettings, "", false, nil, nil, newObservabilityConsumerSender, WithRetry(rCfg), WithQueue(qCfg)) require.NoError(t, err) ocs := be.obsrepSender.(*observabilityConsumerSender) @@ -57,7 +58,7 @@ func TestQueuedRetry_StopWhileWaiting(t *testing.T) { func TestQueuedRetry_DoNotPreserveCancellation(t *testing.T) { qCfg := NewDefaultQueueSettings() qCfg.NumConsumers = 1 - rCfg := NewDefaultRetrySettings() + rCfg := configretry.NewDefaultBackOffConfig() be, err := newBaseExporter(defaultSettings, "", false, nil, nil, newObservabilityConsumerSender, WithRetry(rCfg), WithQueue(qCfg)) require.NoError(t, err) ocs := be.obsrepSender.(*observabilityConsumerSender) @@ -100,7 +101,7 @@ func TestQueuedRetryHappyPath(t *testing.T) { t.Cleanup(func() { require.NoError(t, tt.Shutdown(context.Background())) }) qCfg := NewDefaultQueueSettings() - rCfg := NewDefaultRetrySettings() + rCfg := configretry.NewDefaultBackOffConfig() 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.NewDefaultBackOffConfig() 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) @@ -171,7 +172,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.NewDefaultBackOffConfig() 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) @@ -247,7 +248,7 @@ func TestQueuedRetryPersistenceEnabled(t *testing.T) { qCfg := NewDefaultQueueSettings() storageID := component.NewIDWithName("file_storage", "storage") qCfg.StorageID = &storageID // enable persistence - rCfg := NewDefaultRetrySettings() + rCfg := configretry.NewDefaultBackOffConfig() 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) @@ -271,7 +272,7 @@ func TestQueuedRetryPersistenceEnabledStorageError(t *testing.T) { qCfg := NewDefaultQueueSettings() storageID := component.NewIDWithName("file_storage", "storage") qCfg.StorageID = &storageID // enable persistence - rCfg := NewDefaultRetrySettings() + rCfg := configretry.NewDefaultBackOffConfig() 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) @@ -291,7 +292,7 @@ func TestQueuedRetryPersistentEnabled_NoDataLossOnShutdown(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.NewDefaultBackOffConfig() 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 6ce76ccb8de..6215a314d8d 100644 --- a/exporter/exporterhelper/retry_sender.go +++ b/exporter/exporterhelper/retry_sender.go @@ -14,65 +14,18 @@ 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/exporter/exporterhelper/internal" "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. If set to 0, the retries are never stopped. - 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.BackOffConfig +type RetrySettings = configretry.BackOffConfig -// 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.NewDefaultBackOffConfig +var NewDefaultRetrySettings = configretry.NewDefaultBackOffConfig // TODO: Clean this by forcing all exporters to return an internal error type that always include the information about retries. type throttleRetry struct { @@ -99,12 +52,12 @@ func NewThrottleRetry(err error, delay time.Duration) error { type retrySender struct { baseRequestSender traceAttribute attribute.KeyValue - cfg RetrySettings + cfg configretry.BackOffConfig stopCh chan struct{} logger *zap.Logger } -func newRetrySender(config RetrySettings, set exporter.CreateSettings) *retrySender { +func newRetrySender(config configretry.BackOffConfig, 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 9169858c091..99efd945794 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.NewDefaultBackOffConfig() 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.NewDefaultBackOffConfig() 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.NewDefaultBackOffConfig() 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.NewDefaultBackOffConfig() 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.NewDefaultBackOffConfig() 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.NewDefaultBackOffConfig() 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.NewDefaultBackOffConfig() 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.NewDefaultBackOffConfig() 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 1209f8da2ba..368fe9d1b01 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.NewDefaultBackOffConfig() 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.NewDefaultBackOffConfig() 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 2ea2ac9be35..c99baa28792 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.BackOffConfig { + c := configretry.NewDefaultBackOffConfig() c.InitialInterval = time.Millisecond return c }() diff --git a/exporter/go.mod b/exporter/go.mod index e797de14825..8a9d3e0613a 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,4 +85,8 @@ 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/config/configretry => ../config/configretry + replace go.opentelemetry.io/collector/config/configtelemetry => ../config/configtelemetry + +replace go.opentelemetry.io/collector/connector => ../connector diff --git a/exporter/loggingexporter/go.mod b/exporter/loggingexporter/go.mod index 082e5ae2360..e154f49c943 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 @@ -74,3 +75,5 @@ retract ( ) 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 d276f6e7c87..7c9106ddad4 100644 --- a/exporter/otlpexporter/config.go +++ b/exporter/otlpexporter/config.go @@ -4,29 +4,19 @@ package otlpexporter // import "go.opentelemetry.io/collector/exporter/otlpexporter" import ( - "fmt" - "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/config/configgrpc" + "go.opentelemetry.io/collector/config/configretry" "go.opentelemetry.io/collector/exporter/exporterhelper" ) // Config defines configuration for OTLP exporter. 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"` + exporterhelper.TimeoutSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct. + QueueConfig exporterhelper.QueueSettings `mapstructure:"sending_queue"` + RetryConfig configretry.BackOffConfig `mapstructure:"retry_on_failure"` configgrpc.GRPCClientSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct. } var _ component.Config = (*Config)(nil) - -// Validate checks if the exporter configuration is valid -func (cfg *Config) Validate() error { - if err := cfg.QueueSettings.Validate(); err != nil { - return fmt.Errorf("queue settings has invalid configuration: %w", err) - } - - return nil -} diff --git a/exporter/otlpexporter/config_test.go b/exporter/otlpexporter/config_test.go index ebc1789a41e..78870e34b22 100644 --- a/exporter/otlpexporter/config_test.go +++ b/exporter/otlpexporter/config_test.go @@ -15,6 +15,7 @@ import ( "go.opentelemetry.io/collector/config/configauth" "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/confmap" "go.opentelemetry.io/collector/confmap/confmaptest" @@ -39,7 +40,7 @@ func TestUnmarshalConfig(t *testing.T) { TimeoutSettings: exporterhelper.TimeoutSettings{ Timeout: 10 * time.Second, }, - RetrySettings: exporterhelper.RetrySettings{ + RetryConfig: configretry.BackOffConfig{ Enabled: true, InitialInterval: 10 * time.Second, RandomizationFactor: 0.7, @@ -47,7 +48,7 @@ func TestUnmarshalConfig(t *testing.T) { MaxInterval: 1 * time.Minute, MaxElapsedTime: 10 * time.Minute, }, - QueueSettings: exporterhelper.QueueSettings{ + QueueConfig: exporterhelper.QueueSettings{ Enabled: true, NumConsumers: 2, QueueSize: 10, diff --git a/exporter/otlpexporter/consume_contract_test.go b/exporter/otlpexporter/consume_contract_test.go index 919ce63616e..8ebd2617f9d 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,11 +18,11 @@ import ( ) func testExporterConfig(endpoint string) component.Config { - retryConfig := exporterhelper.NewDefaultRetrySettings() + retryConfig := configretry.NewDefaultBackOffConfig() retryConfig.InitialInterval = time.Millisecond // interval is short for the test purposes return &Config{ - QueueSettings: exporterhelper.QueueSettings{Enabled: false}, - RetrySettings: retryConfig, + QueueConfig: exporterhelper.QueueSettings{Enabled: false}, + RetryConfig: retryConfig, GRPCClientSettings: configgrpc.GRPCClientSettings{ Endpoint: endpoint, TLSSetting: configtls.TLSClientSetting{ diff --git a/exporter/otlpexporter/factory.go b/exporter/otlpexporter/factory.go index 3980216331a..6145b4151f2 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,8 +35,8 @@ func NewFactory() exporter.Factory { func createDefaultConfig() component.Config { return &Config{ TimeoutSettings: exporterhelper.NewDefaultTimeoutSettings(), - RetrySettings: exporterhelper.NewDefaultRetrySettings(), - QueueSettings: exporterhelper.NewDefaultQueueSettings(), + RetryConfig: configretry.NewDefaultBackOffConfig(), + QueueConfig: exporterhelper.NewDefaultQueueSettings(), GRPCClientSettings: configgrpc.GRPCClientSettings{ Headers: map[string]configopaque.String{}, // Default to gzip compression @@ -60,8 +61,8 @@ func createTracesExporter( oce.pushTraces, exporterhelper.WithCapabilities(consumer.Capabilities{MutatesData: false}), exporterhelper.WithTimeout(oCfg.TimeoutSettings), - exporterhelper.WithRetry(oCfg.RetrySettings), - exporterhelper.WithQueue(oCfg.QueueSettings), + exporterhelper.WithRetry(oCfg.RetryConfig), + exporterhelper.WithQueue(oCfg.QueueConfig), exporterhelper.WithStart(oce.start), exporterhelper.WithShutdown(oce.shutdown)) } @@ -80,8 +81,8 @@ func createMetricsExporter( oce.pushMetrics, exporterhelper.WithCapabilities(consumer.Capabilities{MutatesData: false}), exporterhelper.WithTimeout(oCfg.TimeoutSettings), - exporterhelper.WithRetry(oCfg.RetrySettings), - exporterhelper.WithQueue(oCfg.QueueSettings), + exporterhelper.WithRetry(oCfg.RetryConfig), + exporterhelper.WithQueue(oCfg.QueueConfig), exporterhelper.WithStart(oce.start), exporterhelper.WithShutdown(oce.shutdown), ) @@ -101,8 +102,8 @@ func createLogsExporter( oce.pushLogs, exporterhelper.WithCapabilities(consumer.Capabilities{MutatesData: false}), exporterhelper.WithTimeout(oCfg.TimeoutSettings), - exporterhelper.WithRetry(oCfg.RetrySettings), - exporterhelper.WithQueue(oCfg.QueueSettings), + exporterhelper.WithRetry(oCfg.RetryConfig), + exporterhelper.WithQueue(oCfg.QueueConfig), exporterhelper.WithStart(oce.start), exporterhelper.WithShutdown(oce.shutdown), ) diff --git a/exporter/otlpexporter/factory_test.go b/exporter/otlpexporter/factory_test.go index 4ebb0e283ba..c9fabc13b93 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,8 +30,8 @@ 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.QueueSettings, exporterhelper.NewDefaultQueueSettings()) + assert.Equal(t, ocfg.RetryConfig, configretry.NewDefaultBackOffConfig()) + assert.Equal(t, ocfg.QueueConfig, 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 481d05f5821..c42d1755131 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 @@ -119,3 +120,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/otlpexporter/otlp_test.go b/exporter/otlpexporter/otlp_test.go index 3d7d7eef6ff..419bb3a6467 100644 --- a/exporter/otlpexporter/otlp_test.go +++ b/exporter/otlpexporter/otlp_test.go @@ -234,7 +234,7 @@ func TestSendTraces(t *testing.T) { cfg := factory.CreateDefaultConfig().(*Config) // Disable queuing to ensure that we execute the request when calling ConsumeTraces // otherwise we will not see any errors. - cfg.QueueSettings.Enabled = false + cfg.QueueConfig.Enabled = false cfg.GRPCClientSettings = configgrpc.GRPCClientSettings{ Endpoint: ln.Addr().String(), TLSSetting: configtls.TLSClientSetting{ @@ -399,7 +399,7 @@ func TestSendMetrics(t *testing.T) { cfg := factory.CreateDefaultConfig().(*Config) // Disable queuing to ensure that we execute the request when calling ConsumeMetrics // otherwise we will not see any errors. - cfg.QueueSettings.Enabled = false + cfg.QueueConfig.Enabled = false cfg.GRPCClientSettings = configgrpc.GRPCClientSettings{ Endpoint: ln.Addr().String(), TLSSetting: configtls.TLSClientSetting{ @@ -497,7 +497,7 @@ func TestSendTraceDataServerDownAndUp(t *testing.T) { cfg := factory.CreateDefaultConfig().(*Config) // Disable queuing to ensure that we execute the request when calling ConsumeTraces // otherwise we will not see the error. - cfg.QueueSettings.Enabled = false + cfg.QueueConfig.Enabled = false cfg.GRPCClientSettings = configgrpc.GRPCClientSettings{ Endpoint: ln.Addr().String(), TLSSetting: configtls.TLSClientSetting{ @@ -608,7 +608,7 @@ func TestSendTracesOnResourceExhaustion(t *testing.T) { factory := NewFactory() cfg := factory.CreateDefaultConfig().(*Config) - cfg.RetrySettings.InitialInterval = 0 + cfg.RetryConfig.InitialInterval = 0 cfg.GRPCClientSettings = configgrpc.GRPCClientSettings{ Endpoint: ln.Addr().String(), TLSSetting: configtls.TLSClientSetting{ @@ -689,7 +689,7 @@ func TestSendLogData(t *testing.T) { cfg := factory.CreateDefaultConfig().(*Config) // Disable queuing to ensure that we execute the request when calling ConsumeLogs // otherwise we will not see any errors. - cfg.QueueSettings.Enabled = false + cfg.QueueConfig.Enabled = false cfg.GRPCClientSettings = configgrpc.GRPCClientSettings{ Endpoint: ln.Addr().String(), TLSSetting: configtls.TLSClientSetting{ diff --git a/exporter/otlphttpexporter/config.go b/exporter/otlphttpexporter/config.go index 692f7e0124b..3fb9d2bdec4 100644 --- a/exporter/otlphttpexporter/config.go +++ b/exporter/otlphttpexporter/config.go @@ -8,14 +8,15 @@ import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/config/confighttp" + "go.opentelemetry.io/collector/config/configretry" "go.opentelemetry.io/collector/exporter/exporterhelper" ) // Config defines configuration for OTLP/HTTP exporter. 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"` + confighttp.HTTPClientSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct. + QueueConfig exporterhelper.QueueSettings `mapstructure:"sending_queue"` + RetryConfig configretry.BackOffConfig `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 35b2d15a160..0089e13b719 100644 --- a/exporter/otlphttpexporter/config_test.go +++ b/exporter/otlphttpexporter/config_test.go @@ -14,6 +14,7 @@ import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/config/confighttp" "go.opentelemetry.io/collector/config/configopaque" + "go.opentelemetry.io/collector/config/configretry" "go.opentelemetry.io/collector/config/configtls" "go.opentelemetry.io/collector/confmap" "go.opentelemetry.io/collector/confmap/confmaptest" @@ -37,7 +38,7 @@ func TestUnmarshalConfig(t *testing.T) { assert.NoError(t, component.UnmarshalConfig(cm, cfg)) assert.Equal(t, &Config{ - RetrySettings: exporterhelper.RetrySettings{ + RetryConfig: configretry.BackOffConfig{ Enabled: true, InitialInterval: 10 * time.Second, RandomizationFactor: 0.7, @@ -45,7 +46,7 @@ func TestUnmarshalConfig(t *testing.T) { MaxInterval: 1 * time.Minute, MaxElapsedTime: 10 * time.Minute, }, - QueueSettings: exporterhelper.QueueSettings{ + QueueConfig: exporterhelper.QueueSettings{ Enabled: true, NumConsumers: 2, QueueSize: 10, diff --git a/exporter/otlphttpexporter/factory.go b/exporter/otlphttpexporter/factory.go index 4bdbcdf40fd..94a85edbf1c 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,8 +38,8 @@ func NewFactory() exporter.Factory { func createDefaultConfig() component.Config { return &Config{ - RetrySettings: exporterhelper.NewDefaultRetrySettings(), - QueueSettings: exporterhelper.NewDefaultQueueSettings(), + RetryConfig: configretry.NewDefaultBackOffConfig(), + QueueConfig: exporterhelper.NewDefaultQueueSettings(), HTTPClientSettings: confighttp.HTTPClientSettings{ Endpoint: "", Timeout: 30 * time.Second, @@ -91,8 +92,8 @@ func createTracesExporter( exporterhelper.WithCapabilities(consumer.Capabilities{MutatesData: false}), // explicitly disable since we rely on http.Client timeout logic. exporterhelper.WithTimeout(exporterhelper.TimeoutSettings{Timeout: 0}), - exporterhelper.WithRetry(oCfg.RetrySettings), - exporterhelper.WithQueue(oCfg.QueueSettings)) + exporterhelper.WithRetry(oCfg.RetryConfig), + exporterhelper.WithQueue(oCfg.QueueConfig)) } func createMetricsExporter( @@ -117,8 +118,8 @@ func createMetricsExporter( exporterhelper.WithCapabilities(consumer.Capabilities{MutatesData: false}), // explicitly disable since we rely on http.Client timeout logic. exporterhelper.WithTimeout(exporterhelper.TimeoutSettings{Timeout: 0}), - exporterhelper.WithRetry(oCfg.RetrySettings), - exporterhelper.WithQueue(oCfg.QueueSettings)) + exporterhelper.WithRetry(oCfg.RetryConfig), + exporterhelper.WithQueue(oCfg.QueueConfig)) } func createLogsExporter( @@ -143,6 +144,6 @@ func createLogsExporter( exporterhelper.WithCapabilities(consumer.Capabilities{MutatesData: false}), // explicitly disable since we rely on http.Client timeout logic. exporterhelper.WithTimeout(exporterhelper.TimeoutSettings{Timeout: 0}), - exporterhelper.WithRetry(oCfg.RetrySettings), - exporterhelper.WithQueue(oCfg.QueueSettings)) + exporterhelper.WithRetry(oCfg.RetryConfig), + exporterhelper.WithQueue(oCfg.QueueConfig)) } diff --git a/exporter/otlphttpexporter/factory_test.go b/exporter/otlphttpexporter/factory_test.go index ba6d4d1c835..69749831c5e 100644 --- a/exporter/otlphttpexporter/factory_test.go +++ b/exporter/otlphttpexporter/factory_test.go @@ -30,11 +30,11 @@ func TestCreateDefaultConfig(t *testing.T) { assert.True(t, ok) assert.Equal(t, ocfg.HTTPClientSettings.Endpoint, "") assert.Equal(t, ocfg.HTTPClientSettings.Timeout, 30*time.Second, "default timeout is 30 second") - assert.Equal(t, ocfg.RetrySettings.Enabled, true, "default retry is enabled") - assert.Equal(t, ocfg.RetrySettings.MaxElapsedTime, 300*time.Second, "default retry MaxElapsedTime") - assert.Equal(t, ocfg.RetrySettings.InitialInterval, 5*time.Second, "default retry InitialInterval") - assert.Equal(t, ocfg.RetrySettings.MaxInterval, 30*time.Second, "default retry MaxInterval") - assert.Equal(t, ocfg.QueueSettings.Enabled, true, "default sending queue is enabled") + assert.Equal(t, ocfg.RetryConfig.Enabled, true, "default retry is enabled") + assert.Equal(t, ocfg.RetryConfig.MaxElapsedTime, 300*time.Second, "default retry MaxElapsedTime") + assert.Equal(t, ocfg.RetryConfig.InitialInterval, 5*time.Second, "default retry InitialInterval") + assert.Equal(t, ocfg.RetryConfig.MaxInterval, 30*time.Second, "default retry MaxInterval") + assert.Equal(t, ocfg.QueueConfig.Enabled, true, "default sending queue is enabled") assert.Equal(t, ocfg.Compression, configcompression.Gzip) } diff --git a/exporter/otlphttpexporter/go.mod b/exporter/otlphttpexporter/go.mod index d46c5f0d101..07c58997adc 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 @@ -119,3 +120,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/exporter/otlphttpexporter/otlp_test.go b/exporter/otlphttpexporter/otlp_test.go index daa54d4b7ea..ce51e8c3159 100644 --- a/exporter/otlphttpexporter/otlp_test.go +++ b/exporter/otlphttpexporter/otlp_test.go @@ -329,8 +329,8 @@ func startLogsExporter(t *testing.T, baseURL string, overrideURL string) exporte func createExporterConfig(baseURL string, defaultCfg component.Config) *Config { cfg := defaultCfg.(*Config) cfg.Endpoint = baseURL - cfg.QueueSettings.Enabled = false - cfg.RetrySettings.Enabled = false + cfg.QueueConfig.Enabled = false + cfg.RetryConfig.Enabled = false return cfg } @@ -514,7 +514,7 @@ func TestErrorResponses(t *testing.T) { cfg := &Config{ TracesEndpoint: fmt.Sprintf("%s/v1/traces", srv.URL), - // Create without QueueSettings and RetrySettings so that ConsumeTraces + // Create without QueueSettings and RetryConfig so that ConsumeTraces // returns the errors that we want to check immediately. } exp, err := createTracesExporter(context.Background(), exportertest.NewNopCreateSettings(), cfg) diff --git a/extension/ballastextension/go.mod b/extension/ballastextension/go.mod index 82f9051b641..1b6e22fc199 100644 --- a/extension/ballastextension/go.mod +++ b/extension/ballastextension/go.mod @@ -72,3 +72,5 @@ retract ( 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/extension/zpagesextension/go.mod b/extension/zpagesextension/go.mod index f474e48e88a..42aef78540c 100644 --- a/extension/zpagesextension/go.mod +++ b/extension/zpagesextension/go.mod @@ -74,3 +74,5 @@ retract ( ) 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 d832601f9b0..2672a305dae 100644 --- a/go.mod +++ b/go.mod @@ -58,6 +58,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 @@ -94,6 +95,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 1f01ab1371e..ee3781a66de 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 d875971fc54..75f876c848a 100644 --- a/processor/batchprocessor/go.mod +++ b/processor/batchprocessor/go.mod @@ -88,3 +88,5 @@ retract ( ) 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 a434df475dc..360cc46a382 100644 --- a/processor/go.mod +++ b/processor/go.mod @@ -80,3 +80,5 @@ replace go.opentelemetry.io/collector/pdata => ../pdata replace go.opentelemetry.io/collector/receiver => ../receiver 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 1657f21ce37..58fce0c61a4 100644 --- a/processor/memorylimiterprocessor/go.mod +++ b/processor/memorylimiterprocessor/go.mod @@ -77,3 +77,5 @@ retract ( ) 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 78eda9378f7..1d053eb25cd 100644 --- a/receiver/go.mod +++ b/receiver/go.mod @@ -82,3 +82,5 @@ replace go.opentelemetry.io/collector/processor => ../processor retract v0.76.0 // Depends on retracted pdata v1.0.0-rc10 module 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 147a26a4306..c12bcd3f680 100644 --- a/receiver/otlpreceiver/go.mod +++ b/receiver/otlpreceiver/go.mod @@ -129,3 +129,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 dd2a12f87d8..ab1ec8d9d53 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 73dcb57025c..ddf51b5fbe7 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