racker/virgo — pull request #325 by fourk (2013-01-11 01:22:46+00:00)
Title: WIP -- Add support in agent for units attached to metrics

## WIP -- Support unit discovery

This allows units to be attached to Metric objects created within the Agent.

### JIRA tasks resolved:
* [CMD-43 Support units discovery in ELE](https://issues.rax.io/browse/CMD-43)
* [CMD-52 Allow users to specify units for agent custom checks](https://issues.rax.io/browse/CMD-52)

### Code changes
* additional positional argument on relevant methods (`ChildCheck:_addMetric`, `Metric:initialize`, `CheckResult:addMetric`) representing unit (expects string or nil value)
* modify `ChildCheck:_handleLine` to handle a modified `line` object (modifications described below)
* modify MySQLCheck to match modified method signature for adding metrics.
* testing

### New functionality

The string format for lines emitted by custom plugins etc. used to be a string like:

`metric `

The new format is:

`metric []`

*note:* unit is ONLY supported on non-string metrics. It is also optional.

***

The representation of Metric has been changed from `{t = metric.type, v = metric.value}` to `{t = metric.type, v = metric.value, u = metric.unit}`

*???*: Do we want to have the `u` key always present, or present only when `u ~= nil` ?

### Still TODO:

* Add correct units to all BaseCheck subclasses as appropriate
* Figure out what documentation needs to be modified
* Make appropriate changes in ele for the AEP to accept the new output format.