@@ -83,9 +83,9 @@ func InstrumentMetrics(rdb redis.UniversalClient, opts ...MetricsOption) error {
83
83
}
84
84
85
85
func 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" )) ... )
89
89
90
90
idleMax , err := conf .meter .Int64ObservableUpDownCounter (
91
91
"db.client.connections.idle.max" ,
@@ -132,14 +132,14 @@ func reportPoolStats(rdb *redis.Client, conf *config) error {
132
132
func (ctx context.Context , o metric.Observer ) error {
133
133
stats := rdb .PoolStats ()
134
134
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 ))
138
138
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 ))
141
141
142
- o .ObserveInt64 (timeouts , int64 (stats .Timeouts ), metric .WithAttributes ( labels ... ))
142
+ o .ObserveInt64 (timeouts , int64 (stats .Timeouts ), metric .WithAttributeSet ( poolAttrs ))
143
143
return nil
144
144
},
145
145
idleMax ,
0 commit comments