-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstats.go
More file actions
81 lines (62 loc) · 2.56 KB
/
Copy pathstats.go
File metadata and controls
81 lines (62 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package xpg
import "time"
// PoolStats is a detached point-in-time snapshot of connection pool statistics.
//
// Counter fields are cumulative for the lifetime of the pool.
type PoolStats struct {
// Current state.
// AcquiredConns is the number of connections currently checked out from the
// pool.
AcquiredConns int32
// ConstructingConns is the number of connections currently being created.
ConstructingConns int32
// IdleConns is the number of currently idle connections.
IdleConns int32
// MaxConns is the maximum number of connections allowed by the pool.
MaxConns int32
// TotalConns is the number of acquired, idle, and constructing connections.
TotalConns int32
// Acquire lifecycle.
// AcquireCount is the cumulative number of successful connection acquires.
AcquireCount int64
// AcquireDuration is the cumulative duration of successful connection
// acquires.
AcquireDuration time.Duration
// CanceledAcquireCount is the cumulative number of connection acquires
// canceled by context cancellation.
CanceledAcquireCount int64
// EmptyAcquireCount is the cumulative number of successful acquires that
// waited because the pool was empty.
EmptyAcquireCount int64
// EmptyAcquireWaitTime is the cumulative time spent waiting on successful
// acquires while the pool was empty.
EmptyAcquireWaitTime time.Duration
// Connection lifecycle.
// NewConnsCount is the cumulative number of connections created by the pool.
NewConnsCount int64
// MaxIdleDestroyCount is the cumulative number of connections closed because
// they exceeded MaxConnIdleTime.
MaxIdleDestroyCount int64
// MaxLifetimeDestroyCount is the cumulative number of connections closed
// because they exceeded MaxConnLifetime.
MaxLifetimeDestroyCount int64
}
// Stats returns a detached snapshot of the current pool statistics.
func (p *Pool) Stats() PoolStats {
stats := p.pool.Stat()
return PoolStats{
AcquiredConns: stats.AcquiredConns(),
ConstructingConns: stats.ConstructingConns(),
IdleConns: stats.IdleConns(),
MaxConns: stats.MaxConns(),
TotalConns: stats.TotalConns(),
AcquireCount: stats.AcquireCount(),
AcquireDuration: stats.AcquireDuration(),
CanceledAcquireCount: stats.CanceledAcquireCount(),
EmptyAcquireCount: stats.EmptyAcquireCount(),
EmptyAcquireWaitTime: stats.EmptyAcquireWaitTime(),
NewConnsCount: stats.NewConnsCount(),
MaxIdleDestroyCount: stats.MaxIdleDestroyCount(),
MaxLifetimeDestroyCount: stats.MaxLifetimeDestroyCount(),
}
}