@@ -82,6 +82,30 @@ func reportPoolStats(rdb *redis.Client, conf *config) error {
8282 idleAttrs := append (labels , attribute .String ("state" , "idle" ))
8383 usedAttrs := append (labels , attribute .String ("state" , "used" ))
8484
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+
85109 usage , err := conf .meter .AsyncInt64 ().UpDownCounter (
86110 "db.client.connections.usage" ,
87111 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 {
98122 return err
99123 }
100124
125+ redisConf := rdb .Options ()
101126 return conf .meter .RegisterCallback (
102127 []instrument.Asynchronous {
128+ idleMax ,
129+ idleMin ,
130+ connsMax ,
103131 usage ,
104132 timeouts ,
105133 },
106134 func (ctx context.Context ) {
107135 stats := rdb .PoolStats ()
108136
137+ idleMax .Observe (ctx , int64 (redisConf .MinIdleConns ))
138+ idleMin .Observe (ctx , int64 (redisConf .MaxIdleConns ))
139+ connsMax .Observe (ctx , int64 (redisConf .PoolSize ))
140+
109141 usage .Observe (ctx , int64 (stats .IdleConns ), idleAttrs ... )
110142 usage .Observe (ctx , int64 (stats .TotalConns - stats .IdleConns ), usedAttrs ... )
111143
0 commit comments