diff options
Diffstat (limited to 'src/database/sql/sql.go')
| -rw-r--r-- | src/database/sql/sql.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/database/sql/sql.go b/src/database/sql/sql.go index 1ce679d8a6..b0e8894673 100644 --- a/src/database/sql/sql.go +++ b/src/database/sql/sql.go @@ -572,6 +572,22 @@ func (db *DB) SetMaxOpenConns(n int) { } } +// DBStats contains database statistics. +type DBStats struct { + // OpenConnections is the number of open connections to the database. + OpenConnections int +} + +// Stats returns database statistics. +func (db *DB) Stats() DBStats { + db.mu.Lock() + stats := DBStats{ + OpenConnections: db.numOpen, + } + db.mu.Unlock() + return stats +} + // Assumes db.mu is locked. // If there are connRequests and the connection limit hasn't been reached, // then tell the connectionOpener to open new connections. |
