Add slow log for read (#23272)

Signed-off-by: zhenshan.cao <zhenshan.cao@zilliz.com>
This commit is contained in:
zhenshan.cao 2023-04-14 15:30:29 +08:00 committed by GitHub
parent ea7a4cf837
commit a88178a5ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 0 deletions

View File

@ -22,6 +22,7 @@ import (
"os"
"strconv"
"sync"
"time"
"github.com/cockroachdb/errors"
"github.com/golang/protobuf/proto"
@ -59,6 +60,7 @@ import (
)
const moduleName = "Proxy"
const SlowReadSpan = time.Second * 5
// UpdateStateCode updates the state code of Proxy.
func (node *Proxy) UpdateStateCode(code commonpb.StateCode) {
@ -2431,6 +2433,13 @@ func (node *Proxy) Search(ctx context.Context, request *milvuspb.SearchRequest)
zap.Uint64("travel_timestamp", travelTs),
zap.Uint64("guarantee_timestamp", guaranteeTs))
defer func() {
span := tr.ElapseSpan()
if span >= SlowReadSpan {
log.Info(rpcSlow(method), zap.Duration("duration", span))
}
}()
log.Debug(
rpcReceived(method))
@ -2610,6 +2619,19 @@ func (node *Proxy) Query(ctx context.Context, request *milvuspb.QueryRequest) (*
zap.String("collection", request.CollectionName),
zap.Strings("partitions", request.PartitionNames))
defer func() {
span := tr.ElapseSpan()
if span >= SlowReadSpan {
log.Info(
rpcSlow(method),
zap.String("expr", request.Expr),
zap.Strings("OutputFields", request.OutputFields),
zap.Uint64("travel_timestamp", request.TravelTimestamp),
zap.Uint64("guarantee_timestamp", request.GuaranteeTimestamp),
zap.Duration("duration", span))
}
}()
log.Debug(
rpcReceived(method),
zap.String("expr", request.Expr),

View File

@ -30,6 +30,10 @@ func rpcDone(method string) string {
return fmt.Sprintf("%s done", method)
}
func rpcSlow(method string) string {
return fmt.Sprintf("%s slow", method)
}
func rpcFailedToEnqueue(method string) string {
return fmt.Sprintf("%s failed to enqueue", method)
}