Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[exporterhelper] Fix enabled config option for batch sender #10076

Merged
merged 1 commit into from
May 3, 2024
Merged
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
20 changes: 20 additions & 0 deletions .chloggen/batch-sender-fix-enabled-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# 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. otlpreceiver)
component: exporterhelper

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Fix enabled config option for batch sender

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

# 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: []
4 changes: 2 additions & 2 deletions exporter/exporterhelper/batch_sender_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func TestBatchSender_Shutdown(t *testing.T) {
func TestBatchSender_Disabled(t *testing.T) {
cfg := exporterbatcher.NewDefaultConfig()
cfg.Enabled = false
cfg.MaxSizeItems = 10
cfg.MaxSizeItems = 5
be, err := newBaseExporter(defaultSettings, defaultType, newNoopObsrepSender,
WithBatcher(cfg, WithRequestBatchFuncs(fakeBatchMergeFunc, fakeBatchMergeSplitFunc)))
require.NotNil(t, be)
Expand All @@ -220,7 +220,7 @@ func TestBatchSender_Disabled(t *testing.T) {
})

sink := newFakeRequestSink()
// should be sent right away because batching is disabled.
// should be sent right away without splitting because batching is disabled.
require.NoError(t, be.send(context.Background(), &fakeRequest{items: 8, sink: sink}))
assert.Equal(t, uint64(1), sink.requestsCount.Load())
assert.Equal(t, uint64(8), sink.itemsCount.Load())
Expand Down
4 changes: 4 additions & 0 deletions exporter/exporterhelper/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ func WithRequestBatchFuncs(mf exporterbatcher.BatchMergeFunc[Request], msf expor
// until https://github.com/open-telemetry/opentelemetry-collector/issues/8122 is resolved.
func WithBatcher(cfg exporterbatcher.Config, opts ...BatcherOption) Option {
return func(o *baseExporter) error {
if !cfg.Enabled {
return nil
}

bs := newBatchSender(cfg, o.set, o.batchMergeFunc, o.batchMergeSplitfunc)
for _, opt := range opts {
if err := opt(bs); err != nil {
Expand Down
Loading