MCPcopy
hub / github.com/redis/go-redis / ProcessPipelineHook

Method ProcessPipelineHook

extra/redisotel/metrics.go:318–338  ·  view source on GitHub ↗
(
	hook redis.ProcessPipelineHook,
)

Source from the content-addressed store, hash-verified

316}
317
318func (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
340func milliseconds(d time.Duration) float64 {
341 return float64(d) / float64(time.Millisecond)

Callers

nothing calls this directly

Calls 6

hookStruct · 0.85
statusAttrFunction · 0.85
errorTypeAttributeFunction · 0.85
millisecondsFunction · 0.85
RecordMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected