@@ -83,9 +83,9 @@ func InstrumentMetrics(rdb redis.UniversalClient, opts ...MetricsOption) error {
8383}
8484
8585func reportPoolStats (rdb * redis.Client , conf * config ) error {
86- labels := conf .attrs
87- idleAttrs := append (labels , attribute .String ("state" , "idle" ))
88- usedAttrs := append (labels , attribute .String ("state" , "used" ))
86+ poolAttrs := attribute . NewSet ( conf .attrs ... )
87+ idleAttrs := attribute . NewSet ( append (poolAttrs . ToSlice () , attribute .String ("state" , "idle" )) ... )
88+ usedAttrs := attribute . NewSet ( append (poolAttrs . ToSlice () , attribute .String ("state" , "used" )) ... )
8989
9090 idleMax , err := conf .meter .Int64ObservableUpDownCounter (
9191 "db.client.connections.idle.max" ,
@@ -132,14 +132,14 @@ func reportPoolStats(rdb *redis.Client, conf *config) error {
132132 func (ctx context.Context , o metric.Observer ) error {
133133 stats := rdb .PoolStats ()
134134
135- o .ObserveInt64 (idleMax , int64 (redisConf .MaxIdleConns ), metric .WithAttributes ( labels ... ))
136- o .ObserveInt64 (idleMin , int64 (redisConf .MinIdleConns ), metric .WithAttributes ( labels ... ))
137- o .ObserveInt64 (connsMax , int64 (redisConf .PoolSize ), metric .WithAttributes ( labels ... ))
135+ o .ObserveInt64 (idleMax , int64 (redisConf .MaxIdleConns ), metric .WithAttributeSet ( poolAttrs ))
136+ o .ObserveInt64 (idleMin , int64 (redisConf .MinIdleConns ), metric .WithAttributeSet ( poolAttrs ))
137+ o .ObserveInt64 (connsMax , int64 (redisConf .PoolSize ), metric .WithAttributeSet ( poolAttrs ))
138138
139- o .ObserveInt64 (usage , int64 (stats .IdleConns ), metric .WithAttributes (idleAttrs ... ))
140- o .ObserveInt64 (usage , int64 (stats .TotalConns - stats .IdleConns ), metric .WithAttributes (usedAttrs ... ))
139+ o .ObserveInt64 (usage , int64 (stats .IdleConns ), metric .WithAttributeSet (idleAttrs ))
140+ o .ObserveInt64 (usage , int64 (stats .TotalConns - stats .IdleConns ), metric .WithAttributeSet (usedAttrs ))
141141
142- o .ObserveInt64 (timeouts , int64 (stats .Timeouts ), metric .WithAttributes ( labels ... ))
142+ o .ObserveInt64 (timeouts , int64 (stats .Timeouts ), metric .WithAttributeSet ( poolAttrs ))
143143 return nil
144144 },
145145 idleMax ,
0 commit comments