DataDog/dd-agent — pull request #939 by bunelr (2014-05-12 22:09:02+00:00)
Title: Statsd Batching| Allow to send several datapoints in one udp packet

Add dogstatsd support for multi value packets that was already available in statsd, see [here](https://github.com/etsy/statsd/blob/master/stats.js#L188)

This allows, instead of sending packets like:

kafka.request.metadata.time:3|ms\nkafka.request.metadata.time:6|ms\nkafka.request.metadata.time:4|ms

to send packets of the form:

kafka.request.metadata.time:3|ms:6|ms:4|ms

In the original statsd protocol, it is easily done by splitting on the ":" but given that we use the character for the tagging system, we have to take an additional pass on the split to do some reconstruction.
It seems to cost a bit of performance:

Without tags:

````bash
rudy@rudys-mbp:~/workspace/vm/dd-agent$ python -m timeit -r 5 -s "from aggregator import MetricsAggregator; stats=MetricsAggregator('myhost')" "stats.submit_packets('gauge:3|g')"
100000 loops, best of 5: 11.7 usec per loop
rudy@rudys-mbp:~/workspace/vm/dd-agent$ git checkout statsd_batching
Switched to branch 'statsd_batching'
Your branch is up-to-date with 'origin/statsd_batching'.
rudy@rudys-mbp:~/workspace/vm/dd-agent$ python -m timeit -r 5 -s "from aggregator import MetricsAggregator; stats=MetricsAggregator('myhost')" "stats.submit_packets('gauge:3|g')"
100000 loops, best of 5: 15.1 usec per loop
````

With tags:

````bash
rudy@rudys-mbp:~/workspace/vm/dd-agent$ git checkout master
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.
rudy@rudys-mbp:~/workspace/vm/dd-agent$ python -m timeit -r 5 -s "from aggregator import MetricsAggregator; stats=MetricsAggregator('myhost')" "stats.submit_packets('hist:3|ms|#tag1:one,tag2:two')"
100000 loops, best of 5: 20.5 usec per loop
rudy@rudys-mbp:~/workspace/vm/dd-agent$ git checkout statsd_batching
Switched to branch 'statsd_batching'
Your branch is up-to-date with 'origin/statsd_batching'.
rudy@rudys-mbp:~/workspace/vm/dd-agent$ python -m timeit -r 5 -s "from aggregator import MetricsAggregator; stats=MetricsAggregator('myhost')" "stats.submit_packets('hist:3|ms|#tag1:one,tag2:two')"
10000 loops, best of 5: 25.4 usec per loop
````