title: Cassandra Datastax connection pooling monitor/metrics
body: <p>my team is moving from using Astyanax driver (which is deprecated soon if not already) to using Datastax 3.0 driver. </p>
  
  <p>Our code implements Astyanax's ConnectionPoolMonitor class and we capture about 22 different metrics on our connection pool usage. </p>
  
  <p>I am trying to find an equivalent way to do this with Datastax driver. But all I could find is this:
  <a href="https://datastax.github.io/java-driver/manual/pooling/#monitoring-and-tuning-the-pool" rel="nofollow">https://datastax.github.io/java-driver/manual/pooling/#monitoring-and-tuning-the-pool</a></p>
  
  <p>Basically, the example above shows how you can run a background thread that continuously polls Session.State. This seems rather awkward. Astyanax does  callbacks to the classes that implement ConnectionPoolMonitor.</p>
  
  <p>And the amount of info exposed in Session.State is rather limited: connected hosts, inflight queries, open connections, and trashed connections. </p>
  
  <p>Is there a better option out there that I haven't found somehow? How can I capture metrics such as these:</p>
  
  <ul>
  <li>count of when Pool is exhausted, got connection timeout, socket timeout, got not hosts</li>
  <li>count of connection created, closed, borrowed, returned, creation error</li>
  <li>count of host added, removed, down, reactivated/reconnected</li>
  <li>count of exception unknown error, bad request, interrupted, transport error</li>
  </ul>