Add support for metrics, plus some cleanup.

The user-api env code was about the first one we wrote. Bringing it up to our current style. 

Also build some code to make it easy to add metrics to server-side code by using Hakken. This code probably wants to get pulled into a common library but this is to show the process for now.