[PROF-3285] User-friendly handling of slow submissions on shutdown #1601
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.
dd-trace-rb installs a VM
at_exit
handler that allows it to shut down all of its background tasks cleanly, including attempting to submit and remaining traces and profiles.This finishing of background tasks is already protected by timeouts (to make sure we don't just hang if talking to the agent is slow), but can still take a few seconds.
When a user presses ctrl+c, they usually expect their process to finish in a timely manner, and may assume the process hung if it doesn't finish immediately. To clarify what's going on (and tell users that they can press ctrl+c again to force an exit), I've added a nice message that is printed whenever shut down takes longer than 200ms.
Whenever shutdown is fast enough, no message is printed, to avoid extra noise.