Skip to content

Commit f141f84

Browse files
authored
Don't try to start the traces exporter if one isn't configured (#3042)
1 parent 4c7c400 commit f141f84

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

main.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -438,8 +438,10 @@ func mainWithExitCode() flags.ExitCode {
438438
go readTracePipe(mainCtx)
439439
}
440440

441-
if err := exporter.Start(context.Background()); err != nil {
442-
return flags.Failure("Failed to start OTLP exporter: %v", err)
441+
if exporter != nil {
442+
if err := exporter.Start(context.Background()); err != nil {
443+
return flags.Failure("Failed to start OTLP exporter: %v", err)
444+
}
443445
}
444446

445447
// Block waiting for a signal to indicate the program should terminate
@@ -453,11 +455,13 @@ func mainWithExitCode() flags.ExitCode {
453455
}
454456
}
455457

456-
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
457-
defer cancel()
458+
if exporter != nil {
459+
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
460+
defer cancel()
458461

459-
if err := exporter.Shutdown(ctx); err != nil {
460-
log.Infof("Failed to stop exporter: %v", err)
462+
if err := exporter.Shutdown(ctx); err != nil {
463+
log.Infof("Failed to stop exporter: %v", err)
464+
}
461465
}
462466

463467
log.Info("Exiting ...")

0 commit comments

Comments
 (0)