@@ -180,6 +180,7 @@ func addMetricsHook(rdb *redis.Client, conf *config) error {
180
180
createTime : createTime ,
181
181
useTime : useTime ,
182
182
attrs : conf .attrs ,
183
+ attrsFunc : conf .attrsFunc ,
183
184
})
184
185
return nil
185
186
}
@@ -188,6 +189,7 @@ type metricsHook struct {
188
189
createTime metric.Float64Histogram
189
190
useTime metric.Float64Histogram
190
191
attrs []attribute.KeyValue
192
+ attrsFunc func (context.Context ) []attribute.KeyValue
191
193
}
192
194
193
195
var _ redis.Hook = (* metricsHook )(nil )
@@ -219,6 +221,7 @@ func (mh *metricsHook) ProcessHook(hook redis.ProcessHook) redis.ProcessHook {
219
221
220
222
attrs := make ([]attribute.KeyValue , 0 , len (mh .attrs )+ 2 )
221
223
attrs = append (attrs , mh .attrs ... )
224
+ attrs = append (attrs , mh .attrsFunc (ctx )... )
222
225
attrs = append (attrs , attribute .String ("type" , "command" ))
223
226
attrs = append (attrs , statusAttr (err ))
224
227
attrs = append (attrs , semconv .DBOperationName (cmd .FullName ()))
@@ -240,6 +243,7 @@ func (mh *metricsHook) ProcessPipelineHook(
240
243
241
244
attrs := make ([]attribute.KeyValue , 0 , len (mh .attrs )+ 2 )
242
245
attrs = append (attrs , mh .attrs ... )
246
+ attrs = append (attrs , mh .attrsFunc (ctx )... )
243
247
attrs = append (attrs , attribute .String ("type" , "pipeline" ))
244
248
attrs = append (attrs , statusAttr (err ))
245
249
if len (cmds ) > 0 {
0 commit comments