Go: proposal: database/sql: Extend the DBStats struct

Created on 27 Jul 2018  路  6Comments  路  Source: golang/go

The method db.Stats() exposes the DBStats struct that only has the number of connection open.
I would like to include:

  • The number of active connections: db.numOpen - len(db.freeConn)
  • The number of connection requests: len(db.connRequests)
FrozenDueToAge Proposal WaitingForInfo

Most helpful comment

Please inspect tip: https://tip.golang.org/pkg/database/sql/#DBStats

Does this solve your need?

All 6 comments

This would be great to export as a metric. We don't have any insight into what the right size of our connection pools should be, and it's even harder to debug delays when we think that queries are waiting for an open connection.

Please inspect tip: https://tip.golang.org/pkg/database/sql/#DBStats

Does this solve your need?

That's perfect. Thanks @kardianos!

yep, that looks good to me

is this going to be included in go 1.11? I don't see it here https://tip.golang.org/doc/go1.11

It will be in go1.11.

I didn't put it in the release notes.

Was this page helpful?
0 / 5 - 0 ratings