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

Fix nil panic from otlp exporter #6633

Merged
merged 3 commits into from
Nov 29, 2022
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
12 changes: 12 additions & 0 deletions .chloggen/authpanic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# 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: otlpexporter

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Fix nil panic from otlp exporter in case of errors during Start.

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

5 changes: 3 additions & 2 deletions exporter/otlpexporter/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,10 @@ func TestCreateTracesExporter(t *testing.T) {
err = consumer.Start(context.Background(), componenttest.NewNopHost())
if tt.mustFailOnStart {
assert.Error(t, err)
return
} else {
assert.NoError(t, err)
}
assert.NoError(t, err)
// Shutdown is called even when Start fails
err = consumer.Shutdown(context.Background())
if err != nil {
// Since the endpoint of OTLP exporter doesn't actually exist,
Expand Down
6 changes: 4 additions & 2 deletions exporter/otlpexporter/otlp.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ func (e *exporter) start(ctx context.Context, host component.Host) (err error) {
if e.clientConn, err = e.config.GRPCClientSettings.ToClientConn(ctx, host, e.settings, grpc.WithUserAgent(e.userAgent)); err != nil {
return err
}

e.traceExporter = ptraceotlp.NewGRPCClient(e.clientConn)
e.metricExporter = pmetricotlp.NewGRPCClient(e.clientConn)
e.logExporter = plogotlp.NewGRPCClient(e.clientConn)
Expand All @@ -90,7 +89,10 @@ func (e *exporter) start(ctx context.Context, host component.Host) (err error) {
}

func (e *exporter) shutdown(context.Context) error {
return e.clientConn.Close()
if e.clientConn != nil {
return e.clientConn.Close()
}
return nil
}

func (e *exporter) pushTraces(ctx context.Context, td ptrace.Traces) error {
Expand Down