Skip to content

Commit fa1b29f

Browse files
committed
Do not override if parent sizer is not set. Adds tests for case that was not handled before
1 parent 3382a96 commit fa1b29f

File tree

4 files changed

+26
-3
lines changed

4 files changed

+26
-3
lines changed

exporter/exporterhelper/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ The following configuration options can be modified:
3232
- `flush_timeout` (default (if section is defined) = 200 ms): time after which a batch will be sent regardless of its size. Must be a non-zero value
3333
- `min_size` (default (if section is defined) = 8192): the minimum size of a batch.
3434
- `max_size` (default (if section is defined) = 0): the maximum size of a batch, enables batch splitting. The maximum size of a batch should be greater than or equal to the minimum size of a batch. If set to zero, there is no maximum size.
35-
- `sizer` (default (if section is defined) = items): Overrides the sizer set at the `sending_queue` level for batching. Available options:
35+
- `sizer` (default (if section is defined and `sending_queue::sizer` is not set) = items): Overrides the sizer set at the `sending_queue` level for batching. If `sending_queue::sizer` is not set, it defaults to `items`. Available options:
3636
- `items`: number of the smallest parts of each signal (spans, metric data points, log records);
3737
- `bytes`: the size of serialized data in bytes (the least performant option).
3838

exporter/exporterhelper/internal/queuebatch/config.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,12 @@ func (cfg *Config) Unmarshal(conf *confmap.Conf) error {
5353
return err
5454
}
5555

56-
// If the batch sizer is not set and the batch section is nonempty, use the same value as the queue sizer.
57-
if !conf.IsSet("batch::sizer") && conf.IsSet("batch") && conf.Get("batch") != nil {
56+
// If all of the following hold:
57+
// 1. the sizer is set,
58+
// 2. the batch sizer is not set and
59+
// 3. the batch section is nonempty,
60+
// then use the same value as the queue sizer.
61+
if conf.IsSet("sizer") && !conf.IsSet("batch::sizer") && conf.IsSet("batch") && conf.Get("batch") != nil {
5862
cfg.Batch.Get().Sizer = cfg.Sizer
5963
}
6064
return nil

exporter/exporterhelper/internal/queuebatch/config_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,20 @@ func TestUnmarshal(t *testing.T) {
147147
return cfg
148148
},
149149
},
150+
{
151+
path: "batch_set_nonempty_no_explicit_sizer.yaml",
152+
expectedCfg: func() Config {
153+
cfg := newBaseCfg()
154+
cfg.QueueSize = 2000
155+
cfg.Batch = configoptional.Some(BatchConfig{
156+
FlushTimeout: 200 * time.Millisecond,
157+
// Sizer has NOT been overridden by parent sizer
158+
Sizer: request.SizerTypeItems,
159+
MinSize: 100,
160+
})
161+
return cfg
162+
},
163+
},
150164
{
151165
path: "batch_unset.yaml",
152166
// Batch remains unset, sizer override does not apply.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
enabled: true
2+
queue_size: 2000
3+
batch:
4+
# sizer is NOT overridden here by parent sizer, since parent sizer is not set
5+
min_size: 100

0 commit comments

Comments
 (0)