@@ -82,6 +82,30 @@ func reportPoolStats(rdb *redis.Client, conf *config) error {
82
82
idleAttrs := append (labels , attribute .String ("state" , "idle" ))
83
83
usedAttrs := append (labels , attribute .String ("state" , "used" ))
84
84
85
+ idleMax , err := conf .meter .AsyncInt64 ().UpDownCounter (
86
+ "db.client.connections.idle.max" ,
87
+ instrument .WithDescription ("The maximum number of idle open connections allowed" ),
88
+ )
89
+ if err != nil {
90
+ return err
91
+ }
92
+
93
+ idleMin , err := conf .meter .AsyncInt64 ().UpDownCounter (
94
+ "db.client.connections.idle.min" ,
95
+ instrument .WithDescription ("The minimum number of idle open connections allowed" ),
96
+ )
97
+ if err != nil {
98
+ return err
99
+ }
100
+
101
+ connsMax , err := conf .meter .AsyncInt64 ().UpDownCounter (
102
+ "db.client.connections.max" ,
103
+ instrument .WithDescription ("The maximum number of open connections allowed" ),
104
+ )
105
+ if err != nil {
106
+ return err
107
+ }
108
+
85
109
usage , err := conf .meter .AsyncInt64 ().UpDownCounter (
86
110
"db.client.connections.usage" ,
87
111
instrument .WithDescription ("The number of connections that are currently in state described by the state attribute" ),
@@ -98,14 +122,22 @@ func reportPoolStats(rdb *redis.Client, conf *config) error {
98
122
return err
99
123
}
100
124
125
+ redisConf := rdb .Options ()
101
126
return conf .meter .RegisterCallback (
102
127
[]instrument.Asynchronous {
128
+ idleMax ,
129
+ idleMin ,
130
+ connsMax ,
103
131
usage ,
104
132
timeouts ,
105
133
},
106
134
func (ctx context.Context ) {
107
135
stats := rdb .PoolStats ()
108
136
137
+ idleMax .Observe (ctx , int64 (redisConf .MinIdleConns ))
138
+ idleMin .Observe (ctx , int64 (redisConf .MaxIdleConns ))
139
+ connsMax .Observe (ctx , int64 (redisConf .PoolSize ))
140
+
109
141
usage .Observe (ctx , int64 (stats .IdleConns ), idleAttrs ... )
110
142
usage .Observe (ctx , int64 (stats .TotalConns - stats .IdleConns ), usedAttrs ... )
111
143
0 commit comments