Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
net: I would like Dialer.Dial to provide the time it took to do DNS lookups and TCP Connect #12476
When using Dialer.Dial package, I would like to know how long did the DNS queries take to resolve. The reason to know this is because I am building a network debugging tool - TurboBytes Pulse.
My ugly hacky implementation : https://github.com/turbobytes/pulse/blob/master/misc/patch_dialtimer.go
I place the file above inside net package and it provides me the DNS and Connect timings, but it is not nice to ask users of my tool to patch their Go distribution.
I would be nice if Go would provide an alternate Dial method which provides timing data for various steps, as well as some debugging information about DualStack handling, failovers, etc.
Perhaps change Dial's signature to :-
If debug is non-nill, then populate it with all sorts of useful information.
The net package is already far too complex. Currently the net package doesn't provide any timing information at all, so this would add an entirely new kind of API that we would have to support forever. I really don't see this happening.
If you can figure out some way to implement this without making the net package more complex and without changing any of the existing API, please follow the proposal process to suggest it (https://github.com/golang/proposal#readme).
I thought about doing that, but can't. When Dialer.Dial resolves the hostname, it gets all addresses, and tries to fallback to different IP if one of them is not available. It also implements DualStack (Happy eyeballs).
If I resolve by hand, I need to select an IP to connect to, and possibly would have reproduce the complex retry/fallback logic in the net package.
Resolving IP by hand would work if Dialer would have some Dial method which took a list of ips as input instead of single address. Tomorrow, I will make a new issue proposing just that.