( hook redis.ProcessPipelineHook, )
| 143 | } |
| 144 | |
| 145 | func (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 | |
| 187 | func recordError(span trace.Span, err error) { |
| 188 | if err != redis.Nil { |
nothing calls this directly
no test coverage detected