Skip to content

Commit

Permalink
[config/configretry] Allow zero multiplier and arbitrary randomizatio…
Browse files Browse the repository at this point in the history
…n 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 <aboten@lightstep.com>
Co-authored-by: Alex Boten <aboten@lightstep.com>
  • Loading branch information
mx-psi and Alex Boten authored Jan 8, 2024
1 parent 81b1354 commit fb3ed1b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .chloggen/addretrysetvalidation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@ component: "exporterhelper"
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: "Add RetrySettings validation function"

subtext: |
Validate that time.Duration, multiplier values in configretry are non-negative, and randomization_factor is between 0 and 1
# One or more tracking issues or pull requests related to the change
issues: [9089]
4 changes: 2 additions & 2 deletions config/configretry/backoff.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ func (bs *BackOffConfig) Validate() error {
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.Multiplier < 0 {
return errors.New("'multiplier' must be non-negative")
}
if bs.MaxInterval < 0 {
return errors.New("'max_interval' must be non-negative")
Expand Down
9 changes: 8 additions & 1 deletion config/configretry/backoff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,17 @@ func TestInvalidRandomizationFactor(t *testing.T) {
func TestInvalidMultiplier(t *testing.T) {
cfg := NewDefaultBackOffConfig()
assert.NoError(t, cfg.Validate())
cfg.Multiplier = 0
cfg.Multiplier = -1
assert.Error(t, cfg.Validate())
}

func TestZeroMultiplierIsValid(t *testing.T) {
cfg := NewDefaultBackOffConfig()
assert.NoError(t, cfg.Validate())
cfg.Multiplier = 0
assert.NoError(t, cfg.Validate())
}

func TestInvalidMaxInterval(t *testing.T) {
cfg := NewDefaultBackOffConfig()
assert.NoError(t, cfg.Validate())
Expand Down

0 comments on commit fb3ed1b

Please sign in to comment.