Skip to content

Commit

Permalink
refactor: add trace
Browse files Browse the repository at this point in the history
  • Loading branch information
yangdm0209 committed Dec 4, 2024
1 parent 1799244 commit fdf8fea
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 10 deletions.
4 changes: 3 additions & 1 deletion mock/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module github.com/redis/rueidis/mock

go 1.21
go 1.22

toolchain go1.23.3

replace github.com/redis/rueidis => ../

Expand Down
4 changes: 3 additions & 1 deletion om/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module github.com/redis/rueidis/om

go 1.21
go 1.22

toolchain go1.23.3

replace github.com/redis/rueidis => ../

Expand Down
12 changes: 11 additions & 1 deletion pipe.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"io"
"log"
"net"
"os"
"regexp"
Expand Down Expand Up @@ -301,7 +302,7 @@ func _newPipe(connFn func() (net.Conn, error), option *ClientOption, r2ps, nobg
p.background()
}
if p.timeout > 0 && p.pinggap > 0 {
go p.backgroundPing()
//go p.backgroundPing()
}
}
return p, nil
Expand Down Expand Up @@ -419,13 +420,15 @@ func (p *pipe) _backgroundWrite() (err error) {
blocked = multi[i].IsBlock()
}
if !blocked {
log.Printf("flush delay sleep %s, flushDelay:%v time.Since(flushStart):%v\n", flushDelay-time.Since(flushStart), flushDelay, time.Since(flushStart))
time.Sleep(flushDelay - time.Since(flushStart)) // ref: https://github.com/redis/rueidis/issues/156
}
}
}
if ch != nil && multi == nil {
multi = ones
}
log.Printf("multi cmd in queue :%v\n", len(multi))
for _, cmd := range multi {
err = writeCmd(context.Background(), p.w, cmd.Commands())
}
Expand Down Expand Up @@ -853,22 +856,29 @@ func (p *pipe) Do(ctx context.Context, cmd Completed) (resp RedisResult) {
return resp

queue:
_, finishPutQueue := StartTrace(ctx, "pipeline.Do.queue.Put")
ch := p.queue.PutOne(cmd)
finishPutQueue(nil)
_, finishQueue := StartTrace(ctx, "pipeline.Do.queue.Wait")
if ctxCh := ctx.Done(); ctxCh == nil {
resp = <-ch
} else {
select {
case resp = <-ch:
case <-ctxCh:
finishQueue(errors.New("context canceled")) // canceled or timeout go abort wait rep
goto abort
}
}
finishQueue(nil)
atomic.AddInt32(&p.waits, -1)
atomic.AddInt32(&p.recvs, 1)
return resp
abort:
go func(ch chan RedisResult) {
_, finishAbort := StartTrace(ctx, "pipeline.Do.abort")
<-ch
finishAbort(nil)
atomic.AddInt32(&p.waits, -1)
atomic.AddInt32(&p.recvs, 1)
}(ch)
Expand Down
4 changes: 3 additions & 1 deletion rueidiscompat/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module github.com/redis/rueidis/rueidiscompat

go 1.21
go 1.22

toolchain go1.23.3

replace github.com/redis/rueidis => ../

Expand Down
4 changes: 3 additions & 1 deletion rueidishook/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module github.com/redis/rueidis/rueidishook

go 1.21
go 1.22

toolchain go1.23.3

replace (
github.com/redis/rueidis => ../
Expand Down
10 changes: 6 additions & 4 deletions rueidisotel/go.mod
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
module github.com/redis/rueidis/rueidisotel

go 1.21
go 1.22

toolchain go1.23.3

replace github.com/redis/rueidis => ../

require (
github.com/redis/rueidis v1.0.49
go.opentelemetry.io/otel v1.28.0
go.opentelemetry.io/otel/metric v1.28.0
go.opentelemetry.io/otel v1.32.0
go.opentelemetry.io/otel/metric v1.32.0
go.opentelemetry.io/otel/sdk v1.28.0
go.opentelemetry.io/otel/sdk/metric v1.28.0
go.opentelemetry.io/otel/trace v1.28.0
go.opentelemetry.io/otel/trace v1.32.0
)

require (
Expand Down
3 changes: 3 additions & 0 deletions rueidisotel/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,17 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
go.opentelemetry.io/otel v1.28.0 h1:/SqNcYk+idO0CxKEUOtKQClMK/MimZihKYMruSMViUo=
go.opentelemetry.io/otel v1.28.0/go.mod h1:q68ijF8Fc8CnMHKyzqL6akLO46ePnjkgfIMIjUIX9z4=
go.opentelemetry.io/otel v1.32.0/go.mod h1:00DCVSB0RQcnzlwyTfqtxSm+DRr9hpYrHjNGiBHVQIg=
go.opentelemetry.io/otel/metric v1.28.0 h1:f0HGvSl1KRAU1DLgLGFjrwVyismPlnuU6JD6bOeuA5Q=
go.opentelemetry.io/otel/metric v1.28.0/go.mod h1:Fb1eVBFZmLVTMb6PPohq3TO9IIhUisDsbJoL/+uQW4s=
go.opentelemetry.io/otel/metric v1.32.0/go.mod h1:jH7CIbbK6SH2V2wE16W05BHCtIDzauciCRLoc/SyMv8=
go.opentelemetry.io/otel/sdk v1.28.0 h1:b9d7hIry8yZsgtbmM0DKyPWMMUMlK9NEKuIG4aBqWyE=
go.opentelemetry.io/otel/sdk v1.28.0/go.mod h1:oYj7ClPUA7Iw3m+r7GeEjz0qckQRJK2B8zjcZEfu7Pg=
go.opentelemetry.io/otel/sdk/metric v1.28.0 h1:OkuaKgKrgAbYrrY0t92c+cC+2F6hsFNnCQArXCKlg08=
go.opentelemetry.io/otel/sdk/metric v1.28.0/go.mod h1:cWPjykihLAPvXKi4iZc1dpER3Jdq2Z0YLse3moQUCpg=
go.opentelemetry.io/otel/trace v1.28.0 h1:GhQ9cUuQGmNDd5BTCP2dAvv75RdMxEfTmYejp+lkx9g=
go.opentelemetry.io/otel/trace v1.28.0/go.mod h1:jPyXzNPg6da9+38HEwElrQiHlVMTnVfM3/yv2OlIHaI=
go.opentelemetry.io/otel/trace v1.32.0/go.mod h1:+i4rkvCraA+tG6AzwloGaCtkx53Fa+L+V8e9a7YvhT8=
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8=
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY=
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
Expand Down
4 changes: 3 additions & 1 deletion rueidisprob/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module github.com/redis/rueidis/rueidisprob

go 1.21
go 1.22

toolchain go1.23.3

replace github.com/redis/rueidis => ../

Expand Down

0 comments on commit fdf8fea

Please sign in to comment.