Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that moving
hook.ready = true
after theFire
calls would remove the race condition. Afterclose(filling)
would work too but I don't think it's required.Actually, the
filling
channel doesn't seem to be needed at all.This logging code is pretty hard to follow, but I think this is the main loop:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that the code is a bit spaghetti like; but I don't believe that changing
hook.ready
would help:The variable is not being blocked upon.
waitForEventAndReady
doesn't wait for theready
flag, but rather just return the ready flag state.The
filling
variable helps to ensure we block theerr := hook.wrappedHook.Fire(entry)
call, so that we can fill up thehook.entries
channel. Then, once the channel is full, we unblock the Fire call.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry - I misread your response. I believe that depending on the scenario we want to execute, there are more than one way to fix the test. My plan was to change the expectation, as the test current doing the following:
The total number of entries is either 10 or 11, depending on whether the #2 was executed before all the entries were written.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test name is
TestAsyncTelemetryHook_QueueDepth
, so I believe moving theready
location forces the surplus events to be discarded according to the QueueDepth. So it seems like the right way to go.TestAsyncTelemetryHook_CloseDrop
also uses the ready flag, I don't think it tests "CloseDrop" at all.The complexity of this code is pretty absurd, maybe we can revive the "Externalized Telemetry" project and replace it entirely with a better design.