Skip to content

Commit

Permalink
enhance: Optimize ConsistencyLevel and GuaranteeTimestamp log (#34738)
Browse files Browse the repository at this point in the history
/kind improvement

Signed-off-by: bigsheeper <[email protected]>
  • Loading branch information
bigsheeper authored Jul 18, 2024
1 parent f1b2f7b commit c8bf6c8
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions internal/proxy/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -2959,9 +2959,7 @@ func (node *Proxy) search(ctx context.Context, request *milvuspb.SearchRequest)
mustUsePartitionKey: Params.ProxyCfg.MustUsePartitionKey.GetAsBool(),
}

guaranteeTs := request.GuaranteeTimestamp

log := log.Ctx(ctx).With(
log := log.Ctx(ctx).With( // TODO: it might cause some cpu consumption
zap.String("role", typeutil.ProxyRole),
zap.String("db", request.DbName),
zap.String("collection", request.CollectionName),
Expand All @@ -2970,14 +2968,15 @@ func (node *Proxy) search(ctx context.Context, request *milvuspb.SearchRequest)
zap.Any("len(PlaceholderGroup)", len(request.PlaceholderGroup)),
zap.Any("OutputFields", request.OutputFields),
zap.Any("search_params", request.SearchParams),
zap.Uint64("guarantee_timestamp", guaranteeTs),
zap.String("ConsistencyLevel", request.GetConsistencyLevel().String()),
zap.Bool("useDefaultConsistency", request.GetUseDefaultConsistency()),
)

defer func() {
span := tr.ElapseSpan()
if span >= paramtable.Get().ProxyCfg.SlowQuerySpanInSeconds.GetAsDuration(time.Second) {
log.Info(rpcSlow(method), zap.Int64("nq", qt.SearchRequest.GetNq()), zap.Duration("duration", span))
log.Info(rpcSlow(method), zap.Uint64("guarantee_timestamp", qt.GetGuaranteeTimestamp()),
zap.Int64("nq", qt.SearchRequest.GetNq()), zap.Duration("duration", span))
metrics.ProxySlowQueryCount.WithLabelValues(
strconv.FormatInt(paramtable.GetNodeID(), 10),
metrics.SearchLabel,
Expand Down Expand Up @@ -3162,22 +3161,20 @@ func (node *Proxy) hybridSearch(ctx context.Context, request *milvuspb.HybridSea
mustUsePartitionKey: Params.ProxyCfg.MustUsePartitionKey.GetAsBool(),
}

guaranteeTs := request.GuaranteeTimestamp

log := log.Ctx(ctx).With(
zap.String("role", typeutil.ProxyRole),
zap.String("db", request.DbName),
zap.String("collection", request.CollectionName),
zap.Any("partitions", request.PartitionNames),
zap.Any("OutputFields", request.OutputFields),
zap.Uint64("guarantee_timestamp", guaranteeTs),
zap.String("ConsistencyLevel", request.GetConsistencyLevel().String()),
zap.Bool("useDefaultConsistency", request.GetUseDefaultConsistency()),
)

defer func() {
span := tr.ElapseSpan()
if span >= paramtable.Get().ProxyCfg.SlowQuerySpanInSeconds.GetAsDuration(time.Second) {
log.Info(rpcSlow(method), zap.Duration("duration", span))
log.Info(rpcSlow(method), zap.Uint64("guarantee_timestamp", qt.GetGuaranteeTimestamp()), zap.Duration("duration", span))
metrics.ProxySlowQueryCount.WithLabelValues(
strconv.FormatInt(paramtable.GetNodeID(), 10),
metrics.HybridSearchLabel,
Expand Down Expand Up @@ -3433,6 +3430,7 @@ func (node *Proxy) query(ctx context.Context, qt *queryTask) (*milvuspb.QueryRes
zap.String("db", request.DbName),
zap.String("collection", request.CollectionName),
zap.Strings("partitions", request.PartitionNames),
zap.String("ConsistencyLevel", request.GetConsistencyLevel().String()),
zap.Bool("useDefaultConsistency", request.GetUseDefaultConsistency()),
)

Expand All @@ -3441,7 +3439,6 @@ func (node *Proxy) query(ctx context.Context, qt *queryTask) (*milvuspb.QueryRes
zap.String("expr", request.Expr),
zap.Strings("OutputFields", request.OutputFields),
zap.Uint64("travel_timestamp", request.TravelTimestamp),
zap.Uint64("guarantee_timestamp", request.GuaranteeTimestamp),
)

tr := timerecord.NewTimeRecorder(method)
Expand All @@ -3454,7 +3451,7 @@ func (node *Proxy) query(ctx context.Context, qt *queryTask) (*milvuspb.QueryRes
zap.String("expr", request.Expr),
zap.Strings("OutputFields", request.OutputFields),
zap.Uint64("travel_timestamp", request.TravelTimestamp),
zap.Uint64("guarantee_timestamp", request.GuaranteeTimestamp),
zap.Uint64("guarantee_timestamp", qt.GetGuaranteeTimestamp()),
zap.Duration("duration", span))
metrics.ProxySlowQueryCount.WithLabelValues(
strconv.FormatInt(paramtable.GetNodeID(), 10),
Expand Down

0 comments on commit c8bf6c8

Please sign in to comment.