diff --git a/client/client.go b/client/client.go index c417c46851e..b1b6e862e74 100644 --- a/client/client.go +++ b/client/client.go @@ -18,6 +18,7 @@ import ( "context" "fmt" "math/rand" + "runtime/trace" "strings" "sync" "sync/atomic" @@ -823,6 +824,7 @@ func (c *client) GetTSAsync(ctx context.Context) TSFuture { } func (c *client) GetLocalTSAsync(ctx context.Context, dcLocation string) TSFuture { + defer trace.StartRegion(ctx, "GetLocalTSAsync").End() if span := opentracing.SpanFromContext(ctx); span != nil { span = opentracing.StartSpan("GetLocalTSAsync", opentracing.ChildOf(span.Context())) ctx = opentracing.ContextWithSpan(ctx, span) diff --git a/client/tso_dispatcher.go b/client/tso_dispatcher.go index c93c281ec04..a1e4e431e78 100644 --- a/client/tso_dispatcher.go +++ b/client/tso_dispatcher.go @@ -18,6 +18,7 @@ import ( "context" "fmt" "math/rand" + "runtime/trace" "sync" "time" @@ -79,6 +80,8 @@ func (c *tsoClient) dispatchRequest(dcLocation string, request *tsoRequest) erro c.svcDiscovery.ScheduleCheckMemberChanged() return err } + + defer trace.StartRegion(request.requestCtx, "tsoReqEnqueue").End() dispatcher.(*tsoDispatcher).tsoBatchController.tsoRequestCh <- request return nil } @@ -96,6 +99,7 @@ func (req *tsoRequest) Wait() (physical int64, logical int64, err error) { cmdDurationTSOAsyncWait.Observe(start.Sub(req.start).Seconds()) select { case err = <-req.done: + defer trace.StartRegion(req.requestCtx, "tsoReqDone").End() err = errors.WithStack(err) defer tsoReqPool.Put(req) if err != nil { @@ -741,6 +745,9 @@ func (c *tsoClient) processRequests( } requests := tbc.getCollectedRequests() + for _, req := range requests { + defer trace.StartRegion(req.requestCtx, "tsoReqSend").End() + } count := int64(len(requests)) reqKeyspaceGroupID := c.svcDiscovery.GetKeyspaceGroupID() respKeyspaceGroupID, physical, logical, suffixBits, err := stream.processRequests( @@ -830,6 +837,7 @@ func (c *tsoClient) finishRequest(requests []*tsoRequest, physical, firstLogical span.Finish() } requests[i].physical, requests[i].logical = physical, tsoutil.AddLogical(firstLogical, int64(i), suffixBits) + defer trace.StartRegion(requests[i].requestCtx, "tsoReqDequeue").End() requests[i].done <- err } }