Fix wait function
Move try/catch up the stack

Move the try/catch up the stack.  Make sure index_end is always
called.  Define a macro to calculate elapsed time.
Add convenient stat API

Add a convenient set of stat functions rather than sending tuples
directly.

Update latency and throughput stats only when the index or query
operation is successful.  In the case of failure, simply decrement the
pending counter.