Metrics

This is the initial version of the metrics API @rcrichton  and @devcritter please take a look and tell me what you think
There is a lot of repetition of code in each of the case statements. I'd suggest setting up the query object before the switch and then just adding the additional grouping in each case statement and setting the timestamp. Then we could execute the query after the switch. This will make the code a lot cleaner and easier for the next person to maintain. The less code we have to maintain the better! :)