refactored metrics

@rcrichton please review, this is a new branch based on a more recent version of master
@rcrichton , for whatever reason the tests on my shell were not running without that change, each time I ran the tests, the environment was defaulting to development, causing my dev database to get nuked