Fix data race when accessing hostMetrics (#1413)
Fix data race when accessing hostMetrics (#1413)

ObservedQuery and ObservedBatch expose a pointer to hostMetrics struct
to the respective observers. However, the fields of the returned
*hostMetrics are not safe to read, since the observer that might access
hostMetrics' fields is called without the lock held.

In order to return a safe value to clients, we need to make a copy of
the hostMetrics struct while the lock is still locked.

This commit also optimizes the count of lock/unlock calls, previously we
did 3 pairs (for updating attempts, for updating latency and for getting
hostMetrics), now we only do one.
vrischmann/gocql,gocql/gocql,gocql/gocql,vrischmann/gocql,mailgun/gocql,mailgun/gocql