func()

in plugins/go-redisv9/hook.go [125:174]


func (r *redisHook) ProcessPipelineHook(next redis.ProcessPipelineHook) redis.ProcessPipelineHook {
	return func(ctx context.Context, cmds []redis.Cmder) error {
		summary := ""
		summaryCmds := cmds
		if len(summaryCmds) > 10 {
			summaryCmds = summaryCmds[:10]
		}
		for i := range summaryCmds {
			summary += summaryCmds[i].FullName() + "/"
		}
		if len(cmds) > 10 {
			summary += "..."
		}

		var s tracing.Span
		var err error
		if r.Addr != "" {
			s, err = tracing.CreateExitSpan(
				// operationName
				"redis/pipeline",

				// peer
				r.Addr,

				// injector
				func(k, v string) error {
					return nil
				},

				// opts
				tracing.WithComponent(GoRedisComponentID),
				tracing.WithLayer(tracing.SpanLayerCache),
				tracing.WithTag(tracing.TagCacheType, GoRedisCacheType),
				tracing.WithTag(tracing.TagCacheCmd, "pipeline:"+strings.TrimRight(summary, "/")),
			)
			if err != nil {
				err = fmt.Errorf("go-redis :skyWalking failed to create exit span, got error: %v", err)
				return err
			}
			defer s.End()
		}

		if err = next(ctx, cmds); err != nil {
			recordError(s, err)
			return err
		}

		return nil
	}
}