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

Method ProcessPipelineHook

extra/redisotel/tracing.go:145–185  ·  view source on GitHub ↗
(
	hook redis.ProcessPipelineHook,
)

Source from the content-addressed store, hash-verified

143}
144
145func (th *tracingHook) ProcessPipelineHook(
146 hook redis.ProcessPipelineHook,
147) redis.ProcessPipelineHook {
148 return func(ctx context.Context, cmds []redis.Cmder) error {
149
150 if th.conf.filterProcessPipeline != nil && th.conf.filterProcessPipeline(cmds) {
151 return hook(ctx, cmds)
152 }
153
154 attrs := make([]attribute.KeyValue, 0, 8)
155 attrs = append(attrs,
156 attribute.Int("db.redis.num_cmd", len(cmds)),
157 )
158
159 if th.conf.callerEnabled {
160 fn, file, line := funcFileLine("github.com/redis/go-redis")
161 attrs = append(attrs,
162 semconv.CodeFunction(fn),
163 semconv.CodeFilepath(file),
164 semconv.CodeLineNumber(line),
165 )
166 }
167
168 summary, cmdsString := rediscmd.CmdsString(cmds)
169 if th.conf.dbStmtEnabled {
170 attrs = append(attrs, semconv.DBStatement(cmdsString))
171 }
172
173 opts := th.spanOpts
174 opts = append(opts, trace.WithAttributes(attrs...))
175
176 ctx, span := th.conf.tracer.Start(ctx, "redis.pipeline "+summary, opts...)
177 defer span.End()
178
179 if err := hook(ctx, cmds); err != nil {
180 recordError(span, err)
181 return err
182 }
183 return nil
184 }
185}
186
187func recordError(span trace.Span, err error) {
188 if err != redis.Nil {

Callers

nothing calls this directly

Calls 5

hookStruct · 0.85
funcFileLineFunction · 0.85
recordErrorFunction · 0.85
StartMethod · 0.65
IntMethod · 0.45

Tested by

no test coverage detected