Move metrics related functions to lib, include behavior in readme.