Let user determine how to handle socket errors#169
Merged
StephenWakely merged 6 commits intoDataDog:masterfrom Aug 21, 2025
Merged
Let user determine how to handle socket errors#169StephenWakely merged 6 commits intoDataDog:masterfrom
StephenWakely merged 6 commits intoDataDog:masterfrom
Conversation
cosmastech
commented
Aug 20, 2025
StephenWakely
requested changes
Aug 21, 2025
Contributor
StephenWakely
left a comment
There was a problem hiding this comment.
Thank you for this! I just have a small nit around the test...
| })); | ||
|
|
||
| $this->getSocketSpy()->errorThrownOnSend = function () { | ||
| throw new ErrorException('ErrorException: socket_sendto(): Unable to write to socket [111]: Connection refused'); |
Contributor
There was a problem hiding this comment.
It would be more accurate to call trigger_error with E_USER_WARNING here. PHPUnit has an error handler that then throws an ErrorException, so it amounts to the same thing, but just makes it a little clearer what is going on.
Contributor
Author
Thanks for the quick review and merge @StephenWakely 🙇 Do you know when we might expect this functionality to be released in a new version? I want to make some updates to https://github.com/cosmastech/laravel-statsd-adapter as well as our production systems. 😃 |
Contributor
|
@cosmastech It is now released. Thanks for your contribution! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This creates a new parameter for configuration:
flush_failure_handler. This is a callable or null.Why this is necessary: we see socket failures happen far too frequently, and it's very annoying to have to wrap each and every stat write in a try-catch. In our code, we can simply pass something like:
which will write an error to our logs and carry on.
See #168