Add detailed duration timing

Add a contextmanager that can be used to measure and record the duration
of a block. Computed durations will be logged and can optionally be sent
to a StatsD server. This timer is used to heavily instrument the
existing task methods.

Change-Id: I03327ff2cf41c4a51f70d88e402f5e42fc29aa6c