mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-07 01:28:27 +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"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/cockroachdb/errors"
|
"github.com/cockroachdb/errors"
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
@ -59,6 +60,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const moduleName = "Proxy"
|
const moduleName = "Proxy"
|
||||||
|
const SlowReadSpan = time.Second * 5
|
||||||
|
|
||||||
// UpdateStateCode updates the state code of Proxy.
|
// UpdateStateCode updates the state code of Proxy.
|
||||||
func (node *Proxy) UpdateStateCode(code commonpb.StateCode) {
|
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("travel_timestamp", travelTs),
|
||||||
zap.Uint64("guarantee_timestamp", guaranteeTs))
|
zap.Uint64("guarantee_timestamp", guaranteeTs))
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
span := tr.ElapseSpan()
|
||||||
|
if span >= SlowReadSpan {
|
||||||
|
log.Info(rpcSlow(method), zap.Duration("duration", span))
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
log.Debug(
|
log.Debug(
|
||||||
rpcReceived(method))
|
rpcReceived(method))
|
||||||
|
|
||||||
@ -2610,6 +2619,19 @@ func (node *Proxy) Query(ctx context.Context, request *milvuspb.QueryRequest) (*
|
|||||||
zap.String("collection", request.CollectionName),
|
zap.String("collection", request.CollectionName),
|
||||||
zap.Strings("partitions", request.PartitionNames))
|
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(
|
log.Debug(
|
||||||
rpcReceived(method),
|
rpcReceived(method),
|
||||||
zap.String("expr", request.Expr),
|
zap.String("expr", request.Expr),
|
||||||
|
|||||||
@ -30,6 +30,10 @@ func rpcDone(method string) string {
|
|||||||
return fmt.Sprintf("%s done", method)
|
return fmt.Sprintf("%s done", method)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func rpcSlow(method string) string {
|
||||||
|
return fmt.Sprintf("%s slow", method)
|
||||||
|
}
|
||||||
|
|
||||||
func rpcFailedToEnqueue(method string) string {
|
func rpcFailedToEnqueue(method string) string {
|
||||||
return fmt.Sprintf("%s failed to enqueue", method)
|
return fmt.Sprintf("%s failed to enqueue", method)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user