jmxtrans/jmxtrans — pull request #142 by rmarmier (2014-07-02 12:45:48+00:00)
Title: Allowing dots in JMX keys

Hi,
Where I work, we need to pass keys to Graphite without removing the dots inside. I added option 'd' to enable a mode where dots '.' are not normalized into '_'. Default behavior is unchanged. We would like to contribute the solution to JMXTrans.

I first did a small refactoring (first commit). JMXUtils.cleanupStr() now uses precompiled Pattern objects to match characters. It should more efficient and more readable (ok, it's debatable wether RegExps are readable).

While I was at it, I did the same for JMXUtils.isNumeric(). That's the second commit, not strictly necessary.

The third commit implements the optional behavior to ignore dots in keys. I tried to keep the change as small as possible, while keeping things simple and readable. I chose to add a static variable to configure JMXUtils with the correct precompiled Pattern. No need to check on each call, and this choice is not supposed to change at runtime. I can do differently, if asked. [We could turn JMXUtil into a bean and inject it with the correct Pattern object, etc...]

I am available to discuss and do changes as necessary.