-
Notifications
You must be signed in to change notification settings - Fork 3.1k
[connector/datadog] - Use waitgroup instead of closing a channel and waiting on it #40849
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
[connector/datadog] - Use waitgroup instead of closing a channel and waiting on it #40849
Conversation
I like the fix, but I'm wondering if it makes sense to return from the goroutine when the next consumer returns an error (code link) in the first place, instead of |
Yes @jade-guiton-dd. You're right. opentelemetry-collector-contrib/connector/datadogconnector/connector_native.go Lines 154 to 158 in ba9f4b4
and just log the error. Let me know if it's good @songy23 |
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.
Thanks @VihasMakwana LGTM
@songy23 The reason I pinged you was to ask whether it would make sense to replace the whole PR with just |
…waiting on it (open-telemetry#40849) #### Description The `run()` goroutine closes the channel in defer. There are two sceanrios: 1. Best case scenario: no error encountered while calling `ConsumeMetrics`. 2. Worst case scenario: we encounter an error while calling `ConsumeMetrics`, causing the goroutine to exit early and as a result, close the `c.exit` chan. We close the channel, again, in `Shutdown` and this results in a "send on closed channel" panic in worst case scenario. In best case scenario, no panic is encountered. This PR adds waitgroup to avoid the panic. <!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. --> #### Link to tracking issue Fixes open-telemetry#40845 <!--Describe what testing was performed and which tests were added.--> #### Testing Added a test case
Description
The
run()
goroutine closes the channel in defer.There are two sceanrios:
ConsumeMetrics
.ConsumeMetrics
, causing the goroutine to exit early and as a result, close thec.exit
chan.We close the channel, again, in
Shutdown
and this results in a "send on closed channel" panic in worst case scenario. In best case scenario, no panic is encountered.This PR adds waitgroup to avoid the panic.
Link to tracking issue
Fixes #40845
Testing
Added a test case