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

Rename the shutdown channel #3578

Merged
merged 1 commit into from
Jul 8, 2021
Merged
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
13 changes: 6 additions & 7 deletions service/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ type Collector struct {

parserProvider parserprovider.ParserProvider

// stopTestChan is used to terminate the collector server in end to end tests.
stopTestChan chan struct{}
// shutdownChan is used to terminate the collector.
shutdownChan chan struct{}

// signalsChannel is used to receive termination signals from the OS.
signalsChannel chan os.Signal
Expand Down Expand Up @@ -160,10 +160,10 @@ func (col *Collector) Shutdown() {
// See https://github.com/open-telemetry/opentelemetry-collector/issues/483.
defer func() {
if r := recover(); r != nil {
col.logger.Info("stopTestChan already closed")
col.logger.Info("shutdownChan already closed")
}
}()
close(col.stopTestChan)
close(col.shutdownChan)
}

func (col *Collector) setupTelemetry(ballastSizeBytes uint64) error {
Expand All @@ -185,15 +185,14 @@ func (col *Collector) runAndWaitForShutdownEvent() {
col.signalsChannel = make(chan os.Signal, 1)
signal.Notify(col.signalsChannel, os.Interrupt, syscall.SIGTERM)

// set the channel to stop testing.
col.stopTestChan = make(chan struct{})
col.shutdownChan = make(chan struct{})
col.stateChannel <- Running
select {
case err := <-col.asyncErrorChannel:
col.logger.Error("Asynchronous error received, terminating process", zap.Error(err))
case s := <-col.signalsChannel:
col.logger.Info("Received signal from OS", zap.String("signal", s.String()))
case <-col.stopTestChan:
case <-col.shutdownChan:
col.logger.Info("Received stop test request")
}
col.stateChannel <- Closing
Expand Down