Add slow log for read (#23274)

Signed-off-by: zhenshan.cao <zhenshan.cao@zilliz.com>
pull/23284/head
zhenshan.cao 2023-04-07 15:42:32 +08:00 committed by GitHub
parent ac479318d0
commit 5ecec95bf6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 0 deletions

View File

@ -23,6 +23,7 @@ import (
"os"
"strconv"
"sync"
"time"
"github.com/golang/protobuf/proto"
"github.com/milvus-io/milvus-proto/go-api/commonpb"
@ -52,6 +53,7 @@ import (
)
const moduleName = "Proxy"
const SlowReadSpan = time.Second * 5
// UpdateStateCode updates the state code of Proxy.
func (node *Proxy) UpdateStateCode(code commonpb.StateCode) {
@ -2781,6 +2783,25 @@ func (node *Proxy) Search(ctx context.Context, request *milvuspb.SearchRequest)
travelTs := request.TravelTimestamp
guaranteeTs := request.GuaranteeTimestamp
defer func() {
span := tr.ElapseSpan()
if span >= SlowReadSpan {
log.Ctx(ctx).Info(
rpcSlow(method),
zap.String("role", typeutil.ProxyRole),
zap.String("db", request.DbName),
zap.String("collection", request.CollectionName),
zap.Any("partitions", request.PartitionNames),
zap.Any("dsl", request.Dsl),
zap.Any("len(PlaceholderGroup)", len(request.PlaceholderGroup)),
zap.Any("OutputFields", request.OutputFields),
zap.Any("search_params", request.SearchParams),
zap.Uint64("travel_timestamp", travelTs),
zap.Uint64("guarantee_timestamp", guaranteeTs),
zap.Duration("duration", span))
}
}()
log.Ctx(ctx).Debug(
rpcReceived(method),
zap.String("role", typeutil.ProxyRole),
@ -3029,6 +3050,23 @@ func (node *Proxy) Query(ctx context.Context, request *milvuspb.QueryRequest) (*
metrics.ProxyFunctionCall.WithLabelValues(strconv.FormatInt(Params.ProxyCfg.GetNodeID(), 10), method,
metrics.TotalLabel).Inc()
defer func() {
span := tr.ElapseSpan()
if span >= SlowReadSpan {
log.Ctx(ctx).Info(
rpcSlow(method),
zap.String("role", typeutil.ProxyRole),
zap.String("db", request.DbName),
zap.String("collection", request.CollectionName),
zap.Strings("partitions", request.PartitionNames),
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.Ctx(ctx).Debug(
rpcReceived(method),
zap.String("role", typeutil.ProxyRole),

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)
}