1package storage
2
3import "database/sql"
4
5func (s *Store) PoolStats() (own, attached sql.DBStats) {
6 own = s.sql.Stats()
7 s.attachMu.Lock()
8 defer s.attachMu.Unlock()
9 for _, a := range s.attached {
10 for _, pool := range a.pools {
11 st := pool.Stats()
12 attached.MaxOpenConnections += st.MaxOpenConnections
13 attached.OpenConnections += st.OpenConnections
14 attached.InUse += st.InUse
15 attached.Idle += st.Idle
16 attached.WaitCount += st.WaitCount
17 attached.WaitDuration += st.WaitDuration
18 attached.MaxIdleClosed += st.MaxIdleClosed
19 attached.MaxIdleTimeClosed += st.MaxIdleTimeClosed
20 attached.MaxLifetimeClosed += st.MaxLifetimeClosed
21 }
22 }
23 return own, attached
24}