jjagged/metrics-statsd — pull request #3 by gphat (2014-11-08 15:43:48+00:00)
Title: Add support for tags embedded in names of stats.

# What this patch does

This patch adds per-metric tags by allowing the user to embed them in to the metric's name. For example the gauge name `thing.whatever[poop]` will be converted to `thing.whatever|g|#poop` when sent to statsd!

# Motivation

The metrics library does not have a facility for tags so we must create metric names (via their string identifier) that are unique for each set of tags. To make the tag notation clear we'll use brackets (i.e. [ ]) to clearly differentiate the tag from the metric's name.

Note: This style of tagging is used in Datadog's [recommended Java libraries](http://docs.datadoghq.com/libraries/#community-java) of [bazaarvoice/metrics-datadog](https://github.com/bazaarvoice/metrics-datadog) and [coursera/metrics-datadog](https://github.com/coursera/metrics-datadog). They unfortunately do not seem to document this behavior clearly anywhere but you can see the code [here](https://github.com/bazaarvoice/metrics-datadog/blob/master/metrics-datadog/src/main/java/com/codahale/metrics/datadog/model/DatadogSeries.java#L21).

# Testing

I've included tests for single tags, multiple tags and also tags with spaces to verify that they are sanitized.

# Thanks!

I appreciate you looking this over. Please let me know if I can do any more work to make this PR acceptable. This functionality is essential to a project I'm working on and I would love to use it as soon as I can!