( hook redis.ProcessPipelineHook, )
| 316 | } |
| 317 | |
| 318 | func (mh *metricsHook) ProcessPipelineHook( |
| 319 | hook redis.ProcessPipelineHook, |
| 320 | ) redis.ProcessPipelineHook { |
| 321 | return func(ctx context.Context, cmds []redis.Cmder) error { |
| 322 | start := time.Now() |
| 323 | |
| 324 | err := hook(ctx, cmds) |
| 325 | |
| 326 | dur := time.Since(start) |
| 327 | |
| 328 | attrs := make([]attribute.KeyValue, 0, len(mh.attrs)+3) |
| 329 | attrs = append(attrs, mh.attrs...) |
| 330 | attrs = append(attrs, attribute.String("type", "pipeline")) |
| 331 | attrs = append(attrs, statusAttr(err)) |
| 332 | attrs = append(attrs, errorTypeAttribute(err)) |
| 333 | |
| 334 | mh.useTime.Record(ctx, milliseconds(dur), metric.WithAttributeSet(attribute.NewSet(attrs...))) |
| 335 | |
| 336 | return err |
| 337 | } |
| 338 | } |
| 339 | |
| 340 | func milliseconds(d time.Duration) float64 { |
| 341 | return float64(d) / float64(time.Millisecond) |
nothing calls this directly
no test coverage detected