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

Fix bug when Dns.GetHostEntry() returns addresses in unexpected order #50

Merged
merged 1 commit into from
Nov 15, 2017

Conversation

DanielVukelich
Copy link
Contributor

@DanielVukelich DanielVukelich commented Aug 2, 2017

We ran into an issue where our metrics weren't sending from some servers, but were sending from others. We had difficulty tracking it down because no exceptions were showing up in any of our logs.

It turns out that the issue was with IP address resolution. After calling Dns.GetHostEntry() in StatsUDP.GetIpv4Address, the code would then return the last element in the array, assuming that it would be the IPv4 address. However, on the servers where we were encountering this issue, we discovered that Dns.GetHostEntry() was returning IPv4 first, and IPv6 last. This would then cause errors when metrics got sent over UDP, which was being silently caught and squashed in the try-catch statement in Statsd.Send().

My proposed fix is to iterate through the returned addresses in reverse to find an IPv4 address. If no IPv4 address is found, then generate the same exception that would have been squashed at send-time, but allow the user to catch and handle it themselves.

This issue was previously documented by #4

@yannmh yannmh self-assigned this Nov 15, 2017
@yannmh
Copy link
Member

yannmh commented Nov 15, 2017

@DanielVukelich,

Thanks a lot for your contribution. I apologize for the delay in responding to you

Your changes look good, the CI is fixed and tests are 💚 . Let's merge.

@yannmh yannmh merged commit 3b67cc2 into DataDog:master Nov 15, 2017
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

Successfully merging this pull request may close these issues.

None yet

2 participants