(hook redis.ProcessHook)
| 105 | } |
| 106 | |
| 107 | func (th *tracingHook) ProcessHook(hook redis.ProcessHook) redis.ProcessHook { |
| 108 | return func(ctx context.Context, cmd redis.Cmder) error { |
| 109 | |
| 110 | // Check if the command should be filtered out |
| 111 | if th.conf.filterProcess != nil && th.conf.filterProcess(cmd) { |
| 112 | // If so, just call the next hook |
| 113 | return hook(ctx, cmd) |
| 114 | } |
| 115 | |
| 116 | attrs := make([]attribute.KeyValue, 0, 8) |
| 117 | if th.conf.callerEnabled { |
| 118 | fn, file, line := funcFileLine("github.com/redis/go-redis") |
| 119 | attrs = append(attrs, |
| 120 | semconv.CodeFunction(fn), |
| 121 | semconv.CodeFilepath(file), |
| 122 | semconv.CodeLineNumber(line), |
| 123 | ) |
| 124 | } |
| 125 | |
| 126 | if th.conf.dbStmtEnabled { |
| 127 | cmdString := rediscmd.CmdString(cmd) |
| 128 | attrs = append(attrs, semconv.DBStatement(cmdString)) |
| 129 | } |
| 130 | |
| 131 | opts := th.spanOpts |
| 132 | opts = append(opts, trace.WithAttributes(attrs...)) |
| 133 | |
| 134 | ctx, span := th.conf.tracer.Start(ctx, cmd.FullName(), opts...) |
| 135 | defer span.End() |
| 136 | |
| 137 | if err := hook(ctx, cmd); err != nil { |
| 138 | recordError(span, err) |
| 139 | return err |
| 140 | } |
| 141 | return nil |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | func (th *tracingHook) ProcessPipelineHook( |
| 146 | hook redis.ProcessPipelineHook, |
nothing calls this directly
no test coverage detected