@@ -175,6 +175,7 @@ func addMetricsHook(rdb *redis.Client, conf *config) error {
175
175
createTime : createTime ,
176
176
useTime : useTime ,
177
177
attrs : conf .attrs ,
178
+ attrsFunc : conf .attrsFunc ,
178
179
})
179
180
return nil
180
181
}
@@ -183,6 +184,7 @@ type metricsHook struct {
183
184
createTime metric.Float64Histogram
184
185
useTime metric.Float64Histogram
185
186
attrs []attribute.KeyValue
187
+ attrsFunc func (context.Context ) []attribute.KeyValue
186
188
}
187
189
188
190
var _ redis.Hook = (* metricsHook )(nil )
@@ -214,6 +216,7 @@ func (mh *metricsHook) ProcessHook(hook redis.ProcessHook) redis.ProcessHook {
214
216
215
217
attrs := make ([]attribute.KeyValue , 0 , len (mh .attrs )+ 2 )
216
218
attrs = append (attrs , mh .attrs ... )
219
+ attrs = append (attrs , mh .attrsFunc (ctx )... )
217
220
attrs = append (attrs , attribute .String ("type" , "command" ))
218
221
attrs = append (attrs , statusAttr (err ))
219
222
@@ -235,6 +238,7 @@ func (mh *metricsHook) ProcessPipelineHook(
235
238
236
239
attrs := make ([]attribute.KeyValue , 0 , len (mh .attrs )+ 2 )
237
240
attrs = append (attrs , mh .attrs ... )
241
+ attrs = append (attrs , mh .attrsFunc (ctx )... )
238
242
attrs = append (attrs , attribute .String ("type" , "pipeline" ))
239
243
attrs = append (attrs , statusAttr (err ))
240
244
0 commit comments