Skip to content
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

DNS support for UDP transport #66

Open
captn3m0 opened this issue Jun 29, 2018 · 1 comment
Open

DNS support for UDP transport #66

captn3m0 opened this issue Jun 29, 2018 · 1 comment

Comments

@captn3m0
Copy link

Currently, the code does not resolve domain names for UDP transport:

public function flush($udp_message)
{
// Non - Blocking UDP I/O - Use IP Addresses!
$socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
socket_set_nonblock($socket);
socket_sendto($socket, $udp_message, strlen($udp_message), 0, $this->host, $this->port);
socket_close($socket);
}

I understand the need (keep this entirely non-blocking), but was wondering what would be the right approach for this to be added (willing to file a PR, but want to make sure it can be merged before I go ahead).

/cc @jitendra-1217

@timrourke
Copy link
Contributor

Just spitballing, since I'm just a dude, not a DataDog dude, but I wonder if a reasonable strategy here would be to extract the behavior of sending socket messages out into its own object. Sending data over UDP is a different responsibility from serializing UDP message strings so they conform to dogstatsd (which is what most of DogStatsd is about), and if a user could supply their own "sender" object, the specific send implementation could be made entirely flexible.

An interface called \DataDog\DogStatsd\Sender that supported a single public method send would be nice. Then you could extract the curl send logic and the UDP over IP send logic into their own Sender implementations.

I had to stub global socket functions at the namespace level to test that the global socket_* functions were being called correctly, which is boilerplate I could avoid if I could instead pass DogStatsd a mock of a Sender implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants