diff --git a/.chloggen/14435.yaml b/.chloggen/14435.yaml new file mode 100644 index 00000000000..9cf3ef229c9 --- /dev/null +++ b/.chloggen/14435.yaml @@ -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: [] diff --git a/exporter/exporterhelper/internal/queuebatch/config.go b/exporter/exporterhelper/internal/queuebatch/config.go index 78569b85d82..47eb170de04 100644 --- a/exporter/exporterhelper/internal/queuebatch/config.go +++ b/exporter/exporterhelper/internal/queuebatch/config.go @@ -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 + } } return nil } diff --git a/exporter/exporterhelper/internal/queuebatch/config_test.go b/exporter/exporterhelper/internal/queuebatch/config_test.go index b43bb5aa073..246d7f73016 100644 --- a/exporter/exporterhelper/internal/queuebatch/config_test.go +++ b/exporter/exporterhelper/internal/queuebatch/config_test.go @@ -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)) +} diff --git a/exporter/exporterhelper/internal/queuebatch/testdata/batch_set_nonempty_no_parent_sizer.yaml b/exporter/exporterhelper/internal/queuebatch/testdata/batch_set_nonempty_no_parent_sizer.yaml new file mode 100644 index 00000000000..381cc94b824 --- /dev/null +++ b/exporter/exporterhelper/internal/queuebatch/testdata/batch_set_nonempty_no_parent_sizer.yaml @@ -0,0 +1,5 @@ +num_consumers: 10 +queue_size: 1000 +batch: + flush_timeout: 1s + min_size: 100