Skip to content

Commit 109173d

Browse files
authored
[exporterhelper] Fix enabled config option for batch sender (#10076)
`enabled` config option for batch sender was ignored. This PR fixes it.
1 parent ff7a485 commit 109173d

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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. otlpreceiver)
7+
component: exporterhelper
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Fix enabled config option for batch sender
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [10076]
14+
15+
# Optional: The change log or logs in which this entry should be included.
16+
# e.g. '[user]' or '[user, api]'
17+
# Include 'user' if the change is relevant to end users.
18+
# Include 'api' if there is a change to a library API.
19+
# Default: '[user]'
20+
change_logs: []

exporter/exporterhelper/batch_sender_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ func TestBatchSender_Shutdown(t *testing.T) {
208208
func TestBatchSender_Disabled(t *testing.T) {
209209
cfg := exporterbatcher.NewDefaultConfig()
210210
cfg.Enabled = false
211-
cfg.MaxSizeItems = 10
211+
cfg.MaxSizeItems = 5
212212
be, err := newBaseExporter(defaultSettings, defaultType, newNoopObsrepSender,
213213
WithBatcher(cfg, WithRequestBatchFuncs(fakeBatchMergeFunc, fakeBatchMergeSplitFunc)))
214214
require.NotNil(t, be)
@@ -220,7 +220,7 @@ func TestBatchSender_Disabled(t *testing.T) {
220220
})
221221

222222
sink := newFakeRequestSink()
223-
// should be sent right away because batching is disabled.
223+
// should be sent right away without splitting because batching is disabled.
224224
require.NoError(t, be.send(context.Background(), &fakeRequest{items: 8, sink: sink}))
225225
assert.Equal(t, uint64(1), sink.requestsCount.Load())
226226
assert.Equal(t, uint64(8), sink.itemsCount.Load())

exporter/exporterhelper/common.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,10 @@ func WithRequestBatchFuncs(mf exporterbatcher.BatchMergeFunc[Request], msf expor
172172
// until https://github.com/open-telemetry/opentelemetry-collector/issues/8122 is resolved.
173173
func WithBatcher(cfg exporterbatcher.Config, opts ...BatcherOption) Option {
174174
return func(o *baseExporter) error {
175+
if !cfg.Enabled {
176+
return nil
177+
}
178+
175179
bs := newBatchSender(cfg, o.set, o.batchMergeFunc, o.batchMergeSplitfunc)
176180
for _, opt := range opts {
177181
if err := opt(bs); err != nil {

0 commit comments

Comments
 (0)