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

JaegerReceiver: Do not try to stop if failed to start. Collector service will do that #1434

Merged
merged 1 commit into from
Jul 27, 2020
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
16 changes: 2 additions & 14 deletions receiver/jaegerreceiver/trace_receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,10 @@ func (jr *jReceiver) Start(_ context.Context, host component.Host) error {
var err = componenterror.ErrAlreadyStarted
jr.startOnce.Do(func() {
if err = jr.startAgent(host); err != nil && err != componenterror.ErrAlreadyStarted {
jr.stopTraceReceptionLocked()
return
}

if err = jr.startCollector(host); err != nil && err != componenterror.ErrAlreadyStarted {
jr.stopTraceReceptionLocked()
return
}

Expand All @@ -215,15 +213,10 @@ func (jr *jReceiver) Start(_ context.Context, host component.Host) error {
}

func (jr *jReceiver) Shutdown(context.Context) error {
jr.mu.Lock()
defer jr.mu.Unlock()

return jr.stopTraceReceptionLocked()
}

func (jr *jReceiver) stopTraceReceptionLocked() error {
var err = componenterror.ErrAlreadyStopped
jr.stopOnce.Do(func() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't need to block this PR but Is this stopOnce needed? I believe we decided that collector guarantees Shutdown is only called once. Right now there are a mixture of components with stopOnce so we should probably get rid of all of them if not needed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would address in a separate PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given you removed mu from Shutdown in this PR, I would recommend removing this from Start as well (and may as well remove startOnce / stopOnce as well while you're at it 😄 )

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did I? It is just moved the next line.

jr.mu.Lock()
defer jr.mu.Unlock()
var errs []error

if jr.agentServer != nil {
Expand All @@ -246,11 +239,6 @@ func (jr *jReceiver) stopTraceReceptionLocked() error {
jr.grpc.Stop()
jr.grpc = nil
}
if len(errs) == 0 {
err = nil
return
}
// Otherwise combine all these errors
err = componenterror.CombineErrors(errs)
})

Expand Down