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

Method ProcessHook

extra/redisotel/tracing.go:107–143  ·  view source on GitHub ↗
(hook redis.ProcessHook)

Source from the content-addressed store, hash-verified

105}
106
107func (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
145func (th *tracingHook) ProcessPipelineHook(
146 hook redis.ProcessPipelineHook,

Callers

nothing calls this directly

Calls 5

hookStruct · 0.85
funcFileLineFunction · 0.85
recordErrorFunction · 0.85
StartMethod · 0.65
FullNameMethod · 0.65

Tested by

no test coverage detected