Skip to content

Commit fb3ed1b

Browse files
mx-psiAlex Boten
andauthored
[config/configretry] Allow zero multiplier and arbitrary randomization factor (#9235)
**Description:** Partial revert of #9091 to unblock open-telemetry/opentelemetry-collector-contrib/pull/30167 This does not mean that usage of a zero multiplier or a randomization factor outside of [0,1] is blessed upon by Collector maintainers, just that we need to unblock the release :) --------- Signed-off-by: Alex Boten <[email protected]> Co-authored-by: Alex Boten <[email protected]>
1 parent 81b1354 commit fb3ed1b

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

.chloggen/addretrysetvalidation.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,8 @@ component: "exporterhelper"
99
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
1010
note: "Add RetrySettings validation function"
1111

12+
subtext: |
13+
Validate that time.Duration, multiplier values in configretry are non-negative, and randomization_factor is between 0 and 1
14+
1215
# One or more tracking issues or pull requests related to the change
1316
issues: [9089]

config/configretry/backoff.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ func (bs *BackOffConfig) Validate() error {
5252
if bs.RandomizationFactor < 0 || bs.RandomizationFactor > 1 {
5353
return errors.New("'randomization_factor' must be within [0, 1]")
5454
}
55-
if bs.Multiplier <= 0 {
56-
return errors.New("'multiplier' must be positive")
55+
if bs.Multiplier < 0 {
56+
return errors.New("'multiplier' must be non-negative")
5757
}
5858
if bs.MaxInterval < 0 {
5959
return errors.New("'max_interval' must be non-negative")

config/configretry/backoff_test.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,17 @@ func TestInvalidRandomizationFactor(t *testing.T) {
4343
func TestInvalidMultiplier(t *testing.T) {
4444
cfg := NewDefaultBackOffConfig()
4545
assert.NoError(t, cfg.Validate())
46-
cfg.Multiplier = 0
46+
cfg.Multiplier = -1
4747
assert.Error(t, cfg.Validate())
4848
}
4949

50+
func TestZeroMultiplierIsValid(t *testing.T) {
51+
cfg := NewDefaultBackOffConfig()
52+
assert.NoError(t, cfg.Validate())
53+
cfg.Multiplier = 0
54+
assert.NoError(t, cfg.Validate())
55+
}
56+
5057
func TestInvalidMaxInterval(t *testing.T) {
5158
cfg := NewDefaultBackOffConfig()
5259
assert.NoError(t, cfg.Validate())

0 commit comments

Comments
 (0)