@@ -41,9 +41,13 @@ func Wrap(client redis.UniversalClient) Client {
4141 return contextClusterClient {ClusterClient : client }
4242 case * redis.Ring :
4343 return contextRingClient {Ring : client }
44+ default :
45+ if c , ok := client .(Client ); ok {
46+ return c
47+ }
48+ // Handle the case where client doesn't implement the Client interface
49+ panic (fmt .Sprintf ("unsupported redis client type: %T" , client ))
4450 }
45-
46- return client .(Client )
4751}
4852
4953type contextClient struct {
@@ -126,8 +130,7 @@ func process(ctx context.Context) func(oldProcess func(cmd redis.Cmder) error) f
126130func processPipeline (ctx context.Context ) func (oldProcess func (cmds []redis.Cmder ) error ) func (cmds []redis.Cmder ) error {
127131 return func (oldProcess func (cmds []redis.Cmder ) error ) func (cmds []redis.Cmder ) error {
128132 return func (cmds []redis.Cmder ) error {
129- pipelineSpan , ctx := opentracing .StartSpanFromContext (ctx , "(pipeline)" )
130-
133+ pipelineSpan , pipelineCtx := opentracing .StartSpanFromContext (ctx , "(pipeline)" )
131134 ext .DBType .Set (pipelineSpan , "redis" )
132135
133136 for i := len (cmds ); i > 0 ; i -- {
@@ -136,7 +139,7 @@ func processPipeline(ctx context.Context) func(oldProcess func(cmds []redis.Cmde
136139 cmdName = "(empty command)"
137140 }
138141
139- span , _ := opentracing .StartSpanFromContext (ctx , cmdName )
142+ span , _ := opentracing .StartSpanFromContext (pipelineCtx , cmdName )
140143 ext .DBType .Set (span , "redis" )
141144 ext .DBStatement .Set (span , fmt .Sprintf ("%v" , cmds [i - 1 ].Args ()))
142145 defer span .Finish ()
0 commit comments