Skip to content

Commit

Permalink
fix(agent): update error handling on shutdown (#4012)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbdias authored Sep 9, 2024
1 parent ad3dd79 commit d75ac63
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 5 additions & 5 deletions agent/runner/runstrategy_verbose.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ func (s *Runner) RunVerboseStrategy(ctx context.Context, cfg agentConfig.Config)
s.ui.Infof("%s Starting Agent with name %s...", consoleUI.Emoji_Truck, cfg.Name)

session, err := StartSession(ctx, cfg, &verboseObserver{ui: s.ui}, s.logger)

if err != nil && errors.Is(err, ErrOtlpServerStart) {
s.ui.Errorf("%s Tracetest Agent binds to the OpenTelemetry ports 4317 and 4318 which are used to receive trace information from your system. The agent tried to bind to these ports, but failed.", consoleUI.Emoji_RedCircle)

s.ui.Finish()
if err != nil {
if errors.Is(err, ErrOtlpServerStart) {
s.ui.Errorf("%s Tracetest Agent binds to the OpenTelemetry ports 4317 and 4318 which are used to receive trace information from your system. The agent tried to bind to these ports, but failed.", consoleUI.Emoji_RedCircle)
s.ui.Finish()
}
return err
}

Expand Down
4 changes: 3 additions & 1 deletion agent/runner/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ type Session struct {
}

func (s *Session) Close() {
s.client.Close()
if s != nil && s.client != nil {
s.client.Close()
}
}

func (s *Session) WaitUntilDisconnected() {
Expand Down

0 comments on commit d75ac63

Please sign in to comment.