Skip to content

Commit 3af74e1

Browse files
committed
Default sending_queue.batch.sizer to items when sending_queue.sizer is unset
Signed-off-by: Israel Blancas <[email protected]>
1 parent 8ba3ae3 commit 3af74e1

File tree

4 files changed

+50
-6
lines changed

4 files changed

+50
-6
lines changed

.chloggen/14435.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: bug_fix
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. receiver/otlp)
7+
component: exporter/exporterhelper
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: "Default `sending_queue::batch::sizer` to `items` when `sending_queue::sizer` is unset to avoid validation errors."
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [14435]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# Optional: The change log or logs in which this entry should be included.
21+
# e.g. '[user]' or '[user, api]'
22+
# Include 'user' if the change is relevant to end users.
23+
# Include 'api' if there is a change to a library API.
24+
# Default: '[user]'
25+
change_logs: []

exporter/exporterhelper/internal/queuebatch/config.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,15 @@ func (cfg *Config) Unmarshal(conf *confmap.Conf) error {
5151
}
5252

5353
// If all of the following hold:
54-
// 1. the sizer is set,
55-
// 2. the batch sizer is not set and
56-
// 3. the batch section is nonempty,
57-
// then use the same value as the queue sizer.
58-
if conf.IsSet("sizer") && !conf.IsSet("batch::sizer") && conf.IsSet("batch") && conf.Get("batch") != nil {
59-
cfg.Batch.Get().Sizer = cfg.Sizer
54+
// 1. the batch sizer is not set and
55+
// 2. the batch section is nonempty,
56+
// then use the same value as the queue sizer if set, otherwise default to items.
57+
if !conf.IsSet("batch::sizer") && conf.IsSet("batch") && conf.Get("batch") != nil {
58+
if conf.IsSet("sizer") {
59+
cfg.Batch.Get().Sizer = cfg.Sizer
60+
} else {
61+
cfg.Batch.Get().Sizer = request.SizerTypeItems
62+
}
6063
}
6164
return nil
6265
}

exporter/exporterhelper/internal/queuebatch/config_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,3 +180,14 @@ func TestUnmarshal(t *testing.T) {
180180
})
181181
}
182182
}
183+
184+
func TestUnmarshalBatchSizerDefaultsToItemsWithoutParentSizer(t *testing.T) {
185+
cm, err := confmaptest.LoadConf(filepath.Join("testdata", "batch_set_nonempty_no_parent_sizer.yaml"))
186+
require.NoError(t, err)
187+
188+
var cfg Config
189+
require.NoError(t, cfg.Unmarshal(cm))
190+
require.NotNil(t, cfg.Batch.Get())
191+
assert.Equal(t, request.SizerTypeItems, cfg.Batch.Get().Sizer)
192+
require.NoError(t, xconfmap.Validate(cfg))
193+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
num_consumers: 10
2+
queue_size: 1000
3+
batch:
4+
flush_timeout: 1s
5+
min_size: 100

0 commit comments

Comments
 (0)