Skip to content

Commit

Permalink
[processor/batch] Remove wrong config validation
Browse files Browse the repository at this point in the history
  • Loading branch information
lopes-felipe committed Dec 19, 2024
1 parent 50104db commit 85d33cd
Showing 3 changed files with 12 additions and 8 deletions.
1 change: 0 additions & 1 deletion processor/batchprocessor/README.md
Original file line number Diff line number Diff line change
@@ -37,7 +37,6 @@ ignored as data will be sent immediately, subject to only `send_batch_max_size`.
- `send_batch_max_size` (default = 0): The upper limit of the batch size.
`0` means no upper limit of the batch size.
This property ensures that larger batches are split into smaller units.
It must be greater than or equal to `send_batch_size`.
- `metadata_keys` (default = empty): When set, this processor will
create one batcher instance per distinct combination of values in
the `client.Metadata`.
5 changes: 1 addition & 4 deletions processor/batchprocessor/config.go
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ type Config struct {
// subject to only send_batch_max_size.
SendBatchSize uint32 `mapstructure:"send_batch_size"`

// SendBatchMaxSize is the maximum size of a batch. It must be larger than SendBatchSize.
// SendBatchMaxSize is the maximum size of a batch.
// Larger batches are split into smaller units.
// Default value is 0, that means no maximum size.
SendBatchMaxSize uint32 `mapstructure:"send_batch_max_size"`
@@ -50,9 +50,6 @@ var _ component.Config = (*Config)(nil)

// Validate checks if the processor configuration is valid
func (cfg *Config) Validate() error {
if cfg.SendBatchMaxSize > 0 && cfg.SendBatchMaxSize < cfg.SendBatchSize {
return errors.New("send_batch_max_size must be greater or equal to send_batch_size")
}
uniq := map[string]bool{}
for _, k := range cfg.MetadataKeys {
l := strings.ToLower(k)
14 changes: 11 additions & 3 deletions processor/batchprocessor/config_test.go
Original file line number Diff line number Diff line change
@@ -45,20 +45,28 @@ func TestValidateConfig_DefaultBatchMaxSize(t *testing.T) {
assert.NoError(t, cfg.Validate())
}

func TestValidateConfig_ValidBatchSizes(t *testing.T) {
func TestValidateConfig_ValidBatchSizeLowerThanMaxSize(t *testing.T) {
cfg := &Config{
SendBatchSize: 100,
SendBatchMaxSize: 1000,
}
assert.NoError(t, cfg.Validate())
}

func TestValidateConfig_InvalidBatchSize(t *testing.T) {
func TestValidateConfig_ValidBatchSizeGreaterThanMaxSize(t *testing.T) {
cfg := &Config{
SendBatchSize: 1000,
SendBatchMaxSize: 100,
}
assert.Error(t, cfg.Validate())
assert.NoError(t, cfg.Validate())
}

func TestValidateConfig_ValidBatchSizeEqualsToMaxSize(t *testing.T) {
cfg := &Config{
SendBatchSize: 100,
SendBatchMaxSize: 100,
}
assert.NoError(t, cfg.Validate())
}

func TestValidateConfig_InvalidTimeout(t *testing.T) {

0 comments on commit 85d33cd

Please sign in to comment.