Skip to content
Closed
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/14435.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. receiver/otlp)
component: all

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: "Default `sending_queue::batch::sizer` to `items` when `sending_queue::sizer` is unset to avoid validation errors."

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

# (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: []
15 changes: 9 additions & 6 deletions exporter/exporterhelper/internal/queuebatch/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,15 @@ func (cfg *Config) Unmarshal(conf *confmap.Conf) error {
}

// If all of the following hold:
// 1. the sizer is set,
// 2. the batch sizer is not set and
// 3. the batch section is nonempty,
// then use the same value as the queue sizer.
if conf.IsSet("sizer") && !conf.IsSet("batch::sizer") && conf.IsSet("batch") && conf.Get("batch") != nil {
cfg.Batch.Get().Sizer = cfg.Sizer
// 1. the batch sizer is not set and
// 2. the batch section is nonempty,
// then use the same value as the queue sizer if set, otherwise default to items.
if !conf.IsSet("batch::sizer") && conf.IsSet("batch") && conf.Get("batch") != nil {
if conf.IsSet("sizer") {
cfg.Batch.Get().Sizer = cfg.Sizer
} else {
cfg.Batch.Get().Sizer = request.SizerTypeItems
}
Comment on lines +54 to +62
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this logic is not correct, because if the caller has set a different default for the batch sizer this overwrites that.

I am not sure what happens here, because based on NewDefaultQueueConfig the default should be items. Can you add a test that starts from NewDefaultQueueConfig and proves this bug?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are totally right. Though I reproduced the issue but was wrong.
After doing another review, found the issue is actually fixed. Will close this PR and post a comment in the ticket.

Thanks!

}
return nil
}
Expand Down
11 changes: 11 additions & 0 deletions exporter/exporterhelper/internal/queuebatch/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,14 @@ func TestUnmarshal(t *testing.T) {
})
}
}

func TestUnmarshalBatchSizerDefaultsToItemsWithoutParentSizer(t *testing.T) {
cm, err := confmaptest.LoadConf(filepath.Join("testdata", "batch_set_nonempty_no_parent_sizer.yaml"))
require.NoError(t, err)

var cfg Config
require.NoError(t, cfg.Unmarshal(cm))
require.NotNil(t, cfg.Batch.Get())
assert.Equal(t, request.SizerTypeItems, cfg.Batch.Get().Sizer)
require.NoError(t, xconfmap.Validate(cfg))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
num_consumers: 10
queue_size: 1000
batch:
flush_timeout: 1s
min_size: 100
Loading