pandemicsyn/statsdpy — pull request #2 by dbishop (2012-08-23 18:53:23+00:00)
Title: Better foreground

When run in the foreground, you'll see printed messages. For non-errors receiving metrics, you'll still see one line printed per metric received, but it will include the metric value parts as well.

If there's an error on metric receipt, you'll see that as well (without having to enable "debug" in the config file. This is in the spirit of seeing some output printed regardless of the "debug" value in the config. Plus, this way you won't miss StatsD packet decoding errors (which should be rare) if you ran the daemon with "-f" but didn't have debugging enabled.

Also, I forgot to mention it in the commit message, but when you hit Ctrl-C in foreground mode, it exits more gracefully.

Sample foreground output from running genevent.py:

Running in foreground.
got key: comb_testitem ['1', 'c']
got key: ctest2 ['4', 'c']
got key: ctimertest1 ['200', 'ms']
got key: ctestitem1 ['1', 'c', '@0.5']
got key: gtest ['100', 'g']
got key: gtest ['99', 'g']
got key: testitem ['1', 'c']
got key: testitem ['1', 'c', '@0.5']
got key: timertest ['300', 'ms']
got key: timertest ['400', 'ms']
got key: timertest ['500', 'ms']
error: invalid request [.]
error: invalid request [ ]
error (): not enough fields received
got key: _ [' ', 'c']
error: unsupported stats type
key -> baditem
fields ->['1', 'k']
got key: baditem ['1', 'c', '@']
got key: baditem ['1', 'c', '@wtf']
got key: baditem ['1', 'c', '@05f.6']
got key: badtimer ['5.0f', 'ms']
got key: badgauge ['K', 'g']
error: invalid request [te$t_key !fix{\)\/?@#%th'is^&*be"ok]
got key: gtest ['99', 'g']
...