reinh / statsd

A Ruby Statsd client that isn't a direct port of the Python example code. Because Ruby isn't Python.
MIT License
411 stars 154 forks source link

Add optional IPv6 support #38

Closed aw closed 11 years ago

aw commented 11 years ago

Added a 3rd argument to the StatsD initializer, a boolean which we use to specify if our host is an IPv6 address or not.

I chose to strictly specify the type since we don't want to resolve the host to determine if it's an v4 or v6 (and trust me, OS X will damage your brain when you get into that.. something about the default /etc/hosts having multiple addresses resolving for localhost, and Ruby choosing ::1 as the default for IPSocket.getaddress('localhost').. what a pain.. ANYWAYS.

Here's a first attempt at enabling it. :ocean:

Usage:

$statsd = Statsd.new '::1', 9125, true
raggi commented 11 years ago

Maybe this could be determined by looking at the IP address instead of by a boolean?

raggi commented 11 years ago

e.g.

require 'ipaddr'
IPAddr.new('127.0.0.1').ipv4?

We'll need to do a resolve at socket setup time though, if it's a dns name.

aw commented 11 years ago

Why?

I don't see any advantage in trying to do guesswork on something that is already known. Not to mention the additional overhead and possible issues with yet another dependency.

raggi commented 11 years ago

ipaddr and resolv are in the stdlib. if someone passes a dns name, they do not know if it's ipv4 or ipv6, so I have some problems with the premise "something that is already known".

aw commented 11 years ago

You're right.

When I have time i'll look into writing an improved patch. Thanks!