mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-02 03:48:37 +08:00
Add slow log for read (#23272)
Signed-off-by: zhenshan.cao <zhenshan.cao@zilliz.com>
This commit is contained in:
parent
ea7a4cf837
commit
a88178a5ea
@ -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),
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user