Skip to content
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
23 changes: 22 additions & 1 deletion logging/telemetryhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,25 @@ func createAsyncHookLevels(wrappedHook logrus.Hook, channelDepth uint, maxQueueD
}

go func() {
defer hook.wg.Done()
defer func() {
// flush the channel
moreEntries := true
for moreEntries {
select {
case entry := <-hook.entries:
hook.appendEntry(entry)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think you need to call appendEntry, call hook.wg.Done() and skip the range below

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

At this point, there may or may not be elements in hook.pending.
For every element in hook.entries and hook.pending, there should be a hook.wg.Done()
So, there needs to be two range loops to achieve this.

default:
moreEntries = false
}
}
for range hook.pending {
// The telemetry service is
// exiting. Un-wait for the left out
// messages.
hook.wg.Done()
}
hook.wg.Done()
}()

exit := false
for !exit {
Expand Down Expand Up @@ -126,6 +144,9 @@ func (hook *asyncTelemetryHook) waitForEventAndReady() bool {
func (hook *asyncTelemetryHook) Fire(entry *logrus.Entry) error {
hook.wg.Add(1)
select {
case <-hook.quit:
Copy link
Copy Markdown
Contributor

@algobolson algobolson Mar 4, 2020

Choose a reason for hiding this comment

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

this case should have a hook.wg.Done() ? otherwise where is the .Add(1) consumed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes. thanks for catching this.

// telemetry quit
hook.wg.Done()
case hook.entries <- entry:
default:
hook.wg.Done()
Expand Down