Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .chloggen/12948.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: bug_fix

# 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: "Add validation error for batch config if min_size is greater than queue_size."

# One or more tracking issues or pull requests related to the change
issues: [12948]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# 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: []
13 changes: 10 additions & 3 deletions exporter/exporterhelper/internal/queuebatch/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,16 @@ func (cfg *Config) Validate() error {
return errors.New("persistent queue configured with `storage` only supports `requests` sizer")
}

// Only support items sizer for batch at this moment.
if cfg.Batch != nil && (cfg.Sizer != request.SizerTypeItems && cfg.Sizer != request.SizerTypeBytes) {
return errors.New("`batch` supports only `items` or `bytes` sizer")
if cfg.Batch != nil {
// Only support items or bytes sizer for batch at this moment.
if cfg.Sizer != request.SizerTypeItems && cfg.Sizer != request.SizerTypeBytes {
return errors.New("`batch` supports only `items` or `bytes` sizer")
}

// Avoid situations where the queue is not able to hold any data.
if cfg.Batch.MinSize > cfg.QueueSize {
return errors.New("`min_size` must be less than or equal to `queue_size`")
}
}

return nil
Expand Down
4 changes: 4 additions & 0 deletions exporter/exporterhelper/internal/queuebatch/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ func TestConfig_Validate(t *testing.T) {
cfg.Sizer = request.SizerTypeRequests
require.EqualError(t, cfg.Validate(), "`batch` supports only `items` or `bytes` sizer")

cfg = newTestConfig()
cfg.QueueSize = cfg.Batch.MinSize - 1
require.EqualError(t, cfg.Validate(), "`min_size` must be less than or equal to `queue_size`")

cfg = newTestConfig()
cfg.Sizer = request.SizerTypeBytes
require.NoError(t, cfg.Validate())
Expand Down
Loading