BrightcoveOS/Diamond — pull request #170 by patricksmith (2012-11-06 15:21:34+00:00)
Title: collectors/mongodb: Handle long typed values

After upgrading our MongoDB version to 2.2, I noticed that some values are no longer being published. It appears that with the new version of MongoDB, `serverStatus` will return some value types as `long` types. For example, here is a snippet of the result of a `serverStatus` command using MongoDB shell version 2.2.0:

```javascript
"locks" : {
"." : {
"timeLockedMicros" : {
"R" : NumberLong(200613),
"W" : NumberLong(113698)
},
"timeAcquiringMicros" : {
"R" : NumberLong(226017),
"W" : NumberLong(26966)
}
},
"admin" : {
"timeLockedMicros" : {

},
"timeAcquiringMicros" : {

}
},
"local" : {
"timeLockedMicros" : {
"r" : NumberLong(3922),
"w" : NumberLong(14)
},
"timeAcquiringMicros" : {
"r" : NumberLong(941),
"w" : NumberLong(76)
}
}
}
```

The collector checks that the type is `float` or `int`, so no longer publishes all values.

This commit checks if the type is `long` and, if so, converts the value to a `float` before publishing it. It is possible to have an overflow in this conversion, but that should be practically impossible because the `long`s represent microseconds, whose value should not exceed that of the range of `float`.