Database/sql + lib/pq connection pool metrics

Hi there! Hopefully an easy question about DB connection observability.

I’m using database/sql + lib/pq in my API service and publishing various stats about service performance into a statsd observability stack. I would like to add things like the number of open connections and the number of idle connections to the graphs I’m generating to monitor service health but as far as I can tell there is no way to find that information.

The connection pool seems totally owned by database/sql but there doesn’t look to be any ability to pull info out of that and swapping drivers doesn’t seem like it is a useful option since the stuff I’m interested in is above that layer.

Am I missing something here?

It’s probably better idea to monitor pg server instead.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.