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] Log errors even if retry is not used #9270

Closed
wants to merge 4 commits into from
Closed
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
25 changes: 25 additions & 0 deletions .chloggen/eh_logerrors.yaml
Original file line number Diff line number Diff line change
@@ -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. otlpreceiver)
component: exporterhelper

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: log errors even if component does not use exporter helper retry

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

# (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: [user]
7 changes: 4 additions & 3 deletions exporter/exporterhelper/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,10 @@ func newBaseExporter(set exporter.CreateSettings, signal component.DataType, req
unmarshaler: unmarshaler,
signal: signal,

queueSender: &baseRequestSender{},
obsrepSender: osf(obsReport),
retrySender: &baseRequestSender{},
queueSender: &baseRequestSender{},
obsrepSender: osf(obsReport),
// this is required so that exporters that don't use WithRetry() still get error logs on export failure
retrySender: &errorLoggingRequestSender{logger: set.Logger, message: "Exporting failed"},
timeoutSender: &timeoutSender{cfg: NewDefaultTimeoutSettings()},

set: set,
Expand Down
41 changes: 30 additions & 11 deletions exporter/exporterhelper/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,35 @@ func TestQueueRetryOptionsWithRequestExporter(t *testing.T) {
}

func TestBaseExporterLogging(t *testing.T) {
set := exportertest.NewNopCreateSettings()
logger, observed := observer.New(zap.DebugLevel)
set.Logger = zap.New(logger)
rCfg := configretry.NewDefaultBackOffConfig()
rCfg.Enabled = false
bs, err := newBaseExporter(set, "", true, nil, nil, newNoopObsrepSender, WithRetry(rCfg))
require.Nil(t, err)
require.True(t, bs.requestExporter)
sendErr := bs.send(context.Background(), newErrorRequest())
require.Error(t, sendErr)
tests := []struct {
name string
exporterOptions []Option
}{
{
"no options",
nil,
},
{
"with retry",
func() []Option {
rCfg := configretry.NewDefaultBackOffConfig()
rCfg.Enabled = false
return []Option{WithRetry(rCfg)}
}(),
},
}
for _, test := range tests {
set := exportertest.NewNopCreateSettings()
logger, observed := observer.New(zap.DebugLevel)
set.Logger = zap.New(logger)

bs, err := newBaseExporter(set, "", true, nil, nil, newNoopObsrepSender, test.exporterOptions...)
require.Nil(t, err)
require.True(t, bs.requestExporter)
sendErr := bs.send(context.Background(), newErrorRequest())
require.Error(t, sendErr)

require.Len(t, observed.FilterLevelExact(zap.ErrorLevel).All(), 1)
}

require.Len(t, observed.FilterLevelExact(zap.ErrorLevel).All(), 1)
}
Loading