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

statsd_use_default_route triggers failure on OSX #156

Closed
miketheman opened this issue Sep 2, 2016 · 5 comments
Closed

statsd_use_default_route triggers failure on OSX #156

miketheman opened this issue Sep 2, 2016 · 5 comments
Assignees
Milestone

Comments

@miketheman
Copy link
Contributor

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}'
@yannmh
Copy link
Member

yannmh commented Oct 4, 2016

Fixed with #166.

This will go out with the 0.15.0. Thanks @miketheman !

@yannmh yannmh closed this as completed Oct 4, 2016
@miketheman
Copy link
Contributor Author

@yannmh Thanks - I don't see the fix on any branch, is it hiding somewhere?

@yannmh
Copy link
Member

yannmh commented Oct 5, 2016

Pressed the wrong button ('M̶e̶r̶g̶e̶'→ Close') 🤦

It's now on master 🙇

@miketheman
Copy link
Contributor Author

@yannmh Any chance of an 0.15.0 release anytime soon?

@yannmh
Copy link
Member

yannmh commented Jan 20, 2017

Hey @miketheman,

We are planning a release next week, before Thursday 🚀

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