-
Notifications
You must be signed in to change notification settings - Fork 83
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
Constructor guards #115
Comments
Sounds reasonable to me. |
Okay, so I have a candidate proposal that does not mess with the existing logic, but reorganizes it a bit, gets coverage of new code based upon that; I Hope it not too adventurous, and has some (separated commits) for other things that came up in solving this, but are entirely optional, and can be dropped. https://github.com/Lewiscowles1986/php-datadogstatsd/tree/feature/injectable-transport
Tests
The actual guard portion of this, doesn't have to be owned by this repo. In the README.md I added a section with example to bypass the magic, re-using the Ipv4Udp transport that is part of this PR, so that an example of instrumenting the control I was looking for (bypassing the magic in current constructor) is available. I'm not 💯 sure about the construct with single method interface, but felt that opening and closing the socket separately to the functionality; could make some future testing easier. I Also didn't want to open a long-lived socket (although the classes don't hint at that, the way they are used in one place enforces for-now). The interfaces are pretty stripped-back to deal with PHP 5.6 minimum. Not sure where DataDog is going with that, but I think users would get a lot of benefit rolling up to only 7.4 & 8+ in a future release. |
Thanks for the comprehensive work. For our record keeping, can you please update the PR description with everything you mentioned above? Also thanks for including the fixes for php 8 + PHPUnit. Ill leave the rest of my feedback in the PR itself. |
Due to a mis-configuration at work, our agent host was in some cases not being set.
This led to (luckily dev/qa time) discovering a PHP warning is thrown at runtime if the class is constructed with an incorrect value.
Like a lot of 12-factor apps, we get our value from ENV, which in our case resulted in no errors and a booting app. But warnings silently output.
I think the constructor of
DogStatsTimer
should throw if thehost
configuration is not a valid hostname or IP address. In our case it wasfalse
😂I Know people SHOULD NOT have warnings output in QA or production environments. But separate to that issue, I would be interesting in contributing this change if the authors are amenable.
The text was updated successfully, but these errors were encountered: