-
Notifications
You must be signed in to change notification settings - Fork 318
Closed
Milestone
Description
We often develop on OSX, and use a common settings file to initialize the library.
With the setting of use_default_route on OSX, we trigger this easily-reproducible failure:
>>> from datadog import initialize, statsd
>>> datadog_options = { 'statsd_use_default_route': True }
>>> initialize(**datadog_options)
>>> statsd.increment('test')
No handlers could be found for logger "dogstatsd"
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/miketheman/.../python-2.7.12/lib/python2.7/site-packages/datadog/dogstatsd/base.py", line 153, in increment
self._report(metric, 'c', value, tags, sample_rate)
File "/Users/miketheman/.../python-2.7.12/lib/python2.7/site-packages/datadog/dogstatsd/base.py", line 298, in _report
self._send(encoded)
File "/Users/miketheman/.../python-2.7.12/lib/python2.7/site-packages/datadog/dogstatsd/base.py", line 303, in _send_to_server
(self.socket or self.get_socket()).send(packet.encode(self.encoding))
File "/Users/miketheman/.../python-2.7.12/lib/python2.7/site-packages/datadog/dogstatsd/base.py", line 110, in get_socket
sock.connect((self.host, self.port))
File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 228, in meth
return getattr(self._sock,name)(*args)
TypeError: coercing to Unicode: need string or buffer, NoneType found_get_default_route is failing to find the /proc/net/route file - it doesn't exist on OSX, but the log.error is never seen, None is returned, and used in get_socket, which is an invalid input.
Current unit test confirms that the option is set post-initialize, but not whether the resulting client works. I did not see a relevant integration test for this.
I don't know if the right answer is to add a condition from sys.platform and use the equivalent of something like one of these for OSX:
netstat -rn | grep 'default' | awk '{print $2}'route -n get default | grep 'gateway' | awk '{print $2}'
Reactions are currently unavailable