Metrics

This is the initial version of the metrics API @rcrichton  and @devcritter please take a look and tell me what you think
It seems that the indentation of this file was changed. Could you change it back of consistency?