Metrics

Hi Roman, Can you take a look at this when you have the chance? Everything passes except I need to add some tests for api.js, (coverage tragically fell by 4%) but I don't know what the best way to write the test would be. Also, please look to see if my changes to api.js were like you wanted.

While my tests pass, I have not been able to test it in bumblebee much because the metrics service has been down today. So please don't merge until I have a chance to try it out on different types of queries.
the usual suspect around here is 'new line' - i'm scrolling and scrolling, and cant' see the big picture :)