Skip to content

Commit df6046d

Browse files
committed
Deprecate exporterhelper.RetrySettings in favor of configretry.BackOffConfig
Signed-off-by: Bogdan Drutu <[email protected]>
1 parent ef4a5be commit df6046d

File tree

52 files changed

+366
-202
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+366
-202
lines changed

.chloggen/deprecateretry.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: 'breaking'
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
7+
component: otlpexporter
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Change Config members names to use Config suffix.
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [9091]
14+
15+
# Optional: The change log or logs in which this entry should be included.
16+
# e.g. '[user]' or '[user, api]'
17+
# Include 'user' if the change is relevant to end users.
18+
# Include 'api' if there is a change to a library API.
19+
# Default: '[user]'
20+
change_logs: [api]

.chloggen/deprecateretry_dep.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: 'deprecation'
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
7+
component: "exporterhelper"
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: "Deprecate exporterhelper.RetrySettings in favor of configretry.BackOffConfig"
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [9091]

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ check-contrib:
249249
@$(MAKE) -C $(CONTRIB_PATH) for-all CMD="$(GOCMD) mod edit -replace go.opentelemetry.io/collector/config/confighttp=$(CURDIR)/config/confighttp"
250250
@$(MAKE) -C $(CONTRIB_PATH) for-all CMD="$(GOCMD) mod edit -replace go.opentelemetry.io/collector/config/confignet=$(CURDIR)/config/confignet"
251251
@$(MAKE) -C $(CONTRIB_PATH) for-all CMD="$(GOCMD) mod edit -replace go.opentelemetry.io/collector/config/configopaque=$(CURDIR)/config/configopaque"
252+
@$(MAKE) -C $(CONTRIB_PATH) for-all CMD="$(GOCMD) mod edit -replace go.opentelemetry.io/collector/config/configretry=$(CURDIR)/config/configretry"
252253
@$(MAKE) -C $(CONTRIB_PATH) for-all CMD="$(GOCMD) mod edit -replace go.opentelemetry.io/collector/config/configtelemetry=$(CURDIR)/config/configtelemetry"
253254
@$(MAKE) -C $(CONTRIB_PATH) for-all CMD="$(GOCMD) mod edit -replace go.opentelemetry.io/collector/config/configtls=$(CURDIR)/config/configtls"
254255
@$(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:
292293
@$(MAKE) -C $(CONTRIB_PATH) for-all CMD="$(GOCMD) mod edit -dropreplace go.opentelemetry.io/collector/config/confighttp"
293294
@$(MAKE) -C $(CONTRIB_PATH) for-all CMD="$(GOCMD) mod edit -dropreplace go.opentelemetry.io/collector/config/confignet"
294295
@$(MAKE) -C $(CONTRIB_PATH) for-all CMD="$(GOCMD) mod edit -dropreplace go.opentelemetry.io/collector/config/configopaque"
296+
@$(MAKE) -C $(CONTRIB_PATH) for-all CMD="$(GOCMD) mod edit -dropreplace go.opentelemetry.io/collector/config/configretry"
295297
@$(MAKE) -C $(CONTRIB_PATH) for-all CMD="$(GOCMD) mod edit -dropreplace go.opentelemetry.io/collector/config/configtelemetry"
296298
@$(MAKE) -C $(CONTRIB_PATH) for-all CMD="$(GOCMD) mod edit -dropreplace go.opentelemetry.io/collector/config/configtls"
297299
@$(MAKE) -C $(CONTRIB_PATH) for-all CMD="$(GOCMD) mod edit -dropreplace go.opentelemetry.io/collector/config/internal"

cmd/builder/test/core.builder.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ replaces:
2626
- go.opentelemetry.io/collector/config/confighttp => ${WORKSPACE_DIR}/config/confighttp
2727
- go.opentelemetry.io/collector/config/confignet => ${WORKSPACE_DIR}/config/confignet
2828
- go.opentelemetry.io/collector/config/configopaque => ${WORKSPACE_DIR}/config/configopaque
29+
- go.opentelemetry.io/collector/config/configretry => ${WORKSPACE_DIR}/config/configretry
2930
- go.opentelemetry.io/collector/config/configtelemetry => ${WORKSPACE_DIR}/config/configtelemetry
3031
- go.opentelemetry.io/collector/config/configtls => ${WORKSPACE_DIR}/config/configtls
3132
- go.opentelemetry.io/collector/config/internal => ${WORKSPACE_DIR}/config/internal

cmd/otelcorecol/builder-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ replaces:
3131
- go.opentelemetry.io/collector/config/confighttp => ../../config/confighttp
3232
- go.opentelemetry.io/collector/config/confignet => ../../config/confignet
3333
- go.opentelemetry.io/collector/config/configopaque => ../../config/configopaque
34+
- go.opentelemetry.io/collector/config/configretry => ../../config/configretry
3435
- go.opentelemetry.io/collector/config/configtelemetry => ../../config/configtelemetry
3536
- go.opentelemetry.io/collector/config/configtls => ../../config/configtls
3637
- go.opentelemetry.io/collector/config/internal => ../../config/internal

cmd/otelcorecol/go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ require (
8484
go.opentelemetry.io/collector/config/confighttp v0.91.0 // indirect
8585
go.opentelemetry.io/collector/config/confignet v0.91.0 // indirect
8686
go.opentelemetry.io/collector/config/configopaque v0.91.0 // indirect
87+
go.opentelemetry.io/collector/config/configretry v0.91.0 // indirect
8788
go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect
8889
go.opentelemetry.io/collector/config/configtls v0.91.0 // indirect
8990
go.opentelemetry.io/collector/config/internal v0.91.0 // indirect
@@ -145,6 +146,8 @@ replace go.opentelemetry.io/collector/config/confignet => ../../config/confignet
145146

146147
replace go.opentelemetry.io/collector/config/configopaque => ../../config/configopaque
147148

149+
replace go.opentelemetry.io/collector/config/configretry => ../../config/configretry
150+
148151
replace go.opentelemetry.io/collector/config/configtelemetry => ../../config/configtelemetry
149152

150153
replace go.opentelemetry.io/collector/config/configtls => ../../config/configtls

config/configgrpc/go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ replace go.opentelemetry.io/collector/config/configopaque => ../configopaque
8686

8787
replace go.opentelemetry.io/collector/config/configtls => ../configtls
8888

89+
replace go.opentelemetry.io/collector/config/configretry => ../../config/configretry
90+
8991
replace go.opentelemetry.io/collector/config/configtelemetry => ../configtelemetry
9092

9193
replace go.opentelemetry.io/collector/config/internal => ../internal

config/confighttp/go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,5 @@ replace go.opentelemetry.io/collector/pdata => ../../pdata
8686
replace go.opentelemetry.io/collector/component => ../../component
8787

8888
replace go.opentelemetry.io/collector/consumer => ../../consumer
89+
90+
replace go.opentelemetry.io/collector/config/configretry => ../configretry

config/configretry/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include ../../Makefile.Common

config/configretry/backoff.go

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// Copyright The OpenTelemetry Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package configretry // import "go.opentelemetry.io/collector/config/configretry"
5+
6+
import (
7+
"errors"
8+
"time"
9+
10+
"github.com/cenkalti/backoff/v4"
11+
)
12+
13+
// NewDefaultBackOffConfig returns the default settings for RetryConfig.
14+
func NewDefaultBackOffConfig() BackOffConfig {
15+
return BackOffConfig{
16+
Enabled: true,
17+
InitialInterval: 5 * time.Second,
18+
RandomizationFactor: backoff.DefaultRandomizationFactor,
19+
Multiplier: backoff.DefaultMultiplier,
20+
MaxInterval: 30 * time.Second,
21+
MaxElapsedTime: 5 * time.Minute,
22+
}
23+
}
24+
25+
// BackOffConfig defines configuration for retrying batches in case of export failure.
26+
// The current supported strategy is exponential backoff.
27+
type BackOffConfig struct {
28+
// Enabled indicates whether to not retry sending batches in case of export failure.
29+
Enabled bool `mapstructure:"enabled"`
30+
// InitialInterval the time to wait after the first failure before retrying.
31+
InitialInterval time.Duration `mapstructure:"initial_interval"`
32+
// RandomizationFactor is a random factor used to calculate next backoffs
33+
// Randomized interval = RetryInterval * (1 ± RandomizationFactor)
34+
RandomizationFactor float64 `mapstructure:"randomization_factor"`
35+
// Multiplier is the value multiplied by the backoff interval bounds
36+
Multiplier float64 `mapstructure:"multiplier"`
37+
// MaxInterval is the upper bound on backoff interval. Once this value is reached the delay between
38+
// consecutive retries will always be `MaxInterval`.
39+
MaxInterval time.Duration `mapstructure:"max_interval"`
40+
// MaxElapsedTime is the maximum amount of time (including retries) spent trying to send a request/batch.
41+
// Once this value is reached, the data is discarded. If set to 0, the retries are never stopped.
42+
MaxElapsedTime time.Duration `mapstructure:"max_elapsed_time"`
43+
}
44+
45+
func (bs *BackOffConfig) Validate() error {
46+
if !bs.Enabled {
47+
return nil
48+
}
49+
if bs.InitialInterval < 0 {
50+
return errors.New("'initial_interval' must be non-negative")
51+
}
52+
if bs.RandomizationFactor < 0 || bs.RandomizationFactor > 1 {
53+
return errors.New("'randomization_factor' must be within [0, 1]")
54+
}
55+
if bs.Multiplier <= 0 {
56+
return errors.New("'multiplier' must be positive")
57+
}
58+
if bs.MaxInterval < 0 {
59+
return errors.New("'max_interval' must be non-negative")
60+
}
61+
if bs.MaxElapsedTime < 0 {
62+
return errors.New("'max_elapsed' time must be non-negative")
63+
}
64+
return nil
65+
}

0 commit comments

Comments
 (0)