@@ -180,6 +180,7 @@ func addMetricsHook(rdb *redis.Client, conf *config) error {
180180 createTime : createTime ,
181181 useTime : useTime ,
182182 attrs : conf .attrs ,
183+ attrsFunc : conf .attrsFunc ,
183184 })
184185 return nil
185186}
@@ -188,6 +189,7 @@ type metricsHook struct {
188189 createTime metric.Float64Histogram
189190 useTime metric.Float64Histogram
190191 attrs []attribute.KeyValue
192+ attrsFunc func (context.Context ) []attribute.KeyValue
191193}
192194
193195var _ redis.Hook = (* metricsHook )(nil )
@@ -219,6 +221,7 @@ func (mh *metricsHook) ProcessHook(hook redis.ProcessHook) redis.ProcessHook {
219221
220222 attrs := make ([]attribute.KeyValue , 0 , len (mh .attrs )+ 2 )
221223 attrs = append (attrs , mh .attrs ... )
224+ attrs = append (attrs , mh .attrsFunc (ctx )... )
222225 attrs = append (attrs , attribute .String ("type" , "command" ))
223226 attrs = append (attrs , statusAttr (err ))
224227 attrs = append (attrs , semconv .DBOperationName (cmd .FullName ()))
@@ -240,6 +243,7 @@ func (mh *metricsHook) ProcessPipelineHook(
240243
241244 attrs := make ([]attribute.KeyValue , 0 , len (mh .attrs )+ 2 )
242245 attrs = append (attrs , mh .attrs ... )
246+ attrs = append (attrs , mh .attrsFunc (ctx )... )
243247 attrs = append (attrs , attribute .String ("type" , "pipeline" ))
244248 attrs = append (attrs , statusAttr (err ))
245249 if len (cmds ) > 0 {
0 commit comments