summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBruno Binet <bruno.binet@gmail.com>2014-02-21 16:25:05 (GMT)
committerBruno Binet <bruno.binet@gmail.com>2014-02-21 16:25:05 (GMT)
commit297aae2c619772a1ca1ef01e9f83b9bdc51953b1 (patch)
tree5c31495f0e3479d66c805927951915980bcbec51
parent8e225b5033c14c522d975945947d641e96442b01 (diff)
downloadgstatsd-297aae2c619772a1ca1ef01e9f83b9bdc51953b1.zip
gstatsd-297aae2c619772a1ca1ef01e9f83b9bdc51953b1.tar.gz
gstatsd-297aae2c619772a1ca1ef01e9f83b9bdc51953b1.tar.bz2
split received data on newlines
As described in https://github.com/b/statsd_spec#metric-types--formats the format of exported metrics is UTF8 text, with metrics separated by newlines So this split data on newlines as done in origin statsd implementation: https://github.com/etsy/statsd/blob/master/stats.js#L175-179
-rw-r--r--gstatsd/service.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/gstatsd/service.py b/gstatsd/service.py
index a77beb2..ca9f570 100644
--- a/gstatsd/service.py
+++ b/gstatsd/service.py
@@ -174,7 +174,10 @@ class StatsDaemon(object):
self._sock.bind(self._bindaddr)
while 1:
try:
- self._process(*self._sock.recvfrom(MAX_PACKET))
+ data, _ = self._sock.recvfrom(MAX_PACKET)
+ for p in data.split('\n'):
+ if p:
+ self._process(p)
except Exception, ex:
self.error(str(ex))
@@ -182,7 +185,7 @@ class StatsDaemon(object):
"Shutdown the server"
self.exit("service exiting", code=0)
- def _process(self, data, _):
+ def _process(self, data):
"Process a single packet and update the internal tables."
parts = data.split(':')
if self._debug: