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
This commit is contained in:
parent
8e225b5033
commit
297aae2c61
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue