mirror of https://github.com/milvus-io/milvus.git
enhance: [2.5] Add metrics for parse expression (#39716)
master pr: #39654 Signed-off-by: Cai Zhang <cai.zhang@zilliz.com>pull/39789/head
parent
c2986d4ab9
commit
667c84740c
|
@ -4,6 +4,8 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/cockroachdb/errors"
|
||||
"go.opentelemetry.io/otel"
|
||||
|
@ -347,10 +349,13 @@ func (dr *deleteRunner) Init(ctx context.Context) error {
|
|||
return ErrWithLog(log, "Failed to get collection schema", err)
|
||||
}
|
||||
|
||||
start := time.Now()
|
||||
dr.plan, err = planparserv2.CreateRetrievePlan(dr.schema.schemaHelper, dr.req.GetExpr(), dr.req.GetExprTemplateValues())
|
||||
if err != nil {
|
||||
metrics.ProxyParseExpressionLatency.WithLabelValues(strconv.FormatInt(paramtable.GetNodeID(), 10), "delete", metrics.FailLabel).Observe(float64(time.Since(start).Milliseconds()))
|
||||
return merr.WrapErrAsInputError(merr.WrapErrParameterInvalidMsg("failed to create delete plan: %v", err))
|
||||
}
|
||||
metrics.ProxyParseExpressionLatency.WithLabelValues(strconv.FormatInt(paramtable.GetNodeID(), 10), "delete", metrics.SuccessLabel).Observe(float64(time.Since(start).Milliseconds()))
|
||||
|
||||
if planparserv2.IsAlwaysTruePlan(dr.plan) {
|
||||
return merr.WrapErrAsInputError(merr.WrapErrParameterInvalidMsg("delete plan can't be empty or always true : %s", dr.req.GetExpr()))
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/cockroachdb/errors"
|
||||
"github.com/samber/lo"
|
||||
|
@ -235,11 +236,13 @@ func createCntPlan(expr string, schemaHelper *typeutil.SchemaHelper, exprTemplat
|
|||
},
|
||||
}, nil
|
||||
}
|
||||
start := time.Now()
|
||||
plan, err := planparserv2.CreateRetrievePlan(schemaHelper, expr, exprTemplateValues)
|
||||
if err != nil {
|
||||
metrics.ProxyParseExpressionLatency.WithLabelValues(strconv.FormatInt(paramtable.GetNodeID(), 10), "query", metrics.FailLabel).Observe(float64(time.Since(start).Milliseconds()))
|
||||
return nil, merr.WrapErrAsInputError(merr.WrapErrParameterInvalidMsg("failed to create query plan: %v", err))
|
||||
}
|
||||
|
||||
metrics.ProxyParseExpressionLatency.WithLabelValues(strconv.FormatInt(paramtable.GetNodeID(), 10), "query", metrics.SuccessLabel).Observe(float64(time.Since(start).Milliseconds()))
|
||||
plan.Node.(*planpb.PlanNode_Query).Query.IsCount = true
|
||||
|
||||
return plan, nil
|
||||
|
@ -258,10 +261,13 @@ func (t *queryTask) createPlan(ctx context.Context) error {
|
|||
|
||||
var err error
|
||||
if t.plan == nil {
|
||||
start := time.Now()
|
||||
t.plan, err = planparserv2.CreateRetrievePlan(schema.schemaHelper, t.request.Expr, t.request.GetExprTemplateValues())
|
||||
if err != nil {
|
||||
metrics.ProxyParseExpressionLatency.WithLabelValues(strconv.FormatInt(paramtable.GetNodeID(), 10), "query", metrics.FailLabel).Observe(float64(time.Since(start).Milliseconds()))
|
||||
return merr.WrapErrAsInputError(merr.WrapErrParameterInvalidMsg("failed to create query plan: %v", err))
|
||||
}
|
||||
metrics.ProxyParseExpressionLatency.WithLabelValues(strconv.FormatInt(paramtable.GetNodeID(), 10), "query", metrics.SuccessLabel).Observe(float64(time.Since(start).Milliseconds()))
|
||||
}
|
||||
|
||||
t.request.OutputFields, t.userOutputFields, t.userDynamicFields, err = translateOutputFields(t.request.OutputFields, t.schema, true)
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"fmt"
|
||||
"math"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/cockroachdb/errors"
|
||||
"github.com/samber/lo"
|
||||
|
@ -534,13 +535,16 @@ func (t *searchTask) tryGeneratePlan(params []*commonpb.KeyValuePair, dsl string
|
|||
}
|
||||
|
||||
searchInfo.planInfo.QueryFieldId = annField.GetFieldID()
|
||||
start := time.Now()
|
||||
plan, planErr := planparserv2.CreateSearchPlan(t.schema.schemaHelper, dsl, annsFieldName, searchInfo.planInfo, exprTemplateValues)
|
||||
if planErr != nil {
|
||||
log.Ctx(t.ctx).Warn("failed to create query plan", zap.Error(planErr),
|
||||
zap.String("dsl", dsl), // may be very large if large term passed.
|
||||
zap.String("anns field", annsFieldName), zap.Any("query info", searchInfo.planInfo))
|
||||
metrics.ProxyParseExpressionLatency.WithLabelValues(strconv.FormatInt(paramtable.GetNodeID(), 10), "search", metrics.FailLabel).Observe(float64(time.Since(start).Milliseconds()))
|
||||
return nil, nil, 0, false, merr.WrapErrParameterInvalidMsg("failed to create query plan: %v", planErr)
|
||||
}
|
||||
metrics.ProxyParseExpressionLatency.WithLabelValues(strconv.FormatInt(paramtable.GetNodeID(), 10), "search", metrics.SuccessLabel).Observe(float64(time.Since(start).Milliseconds()))
|
||||
log.Ctx(t.ctx).Debug("create query plan",
|
||||
zap.String("dsl", t.request.Dsl), // may be very large if large term passed.
|
||||
zap.String("anns field", annsFieldName), zap.Any("query info", searchInfo.planInfo))
|
||||
|
|
|
@ -427,6 +427,15 @@ var (
|
|||
Help: "the number of non-zeros in each sparse search task",
|
||||
Buckets: buckets,
|
||||
}, []string{nodeIDLabelName, collectionName})
|
||||
|
||||
ProxyParseExpressionLatency = prometheus.NewHistogramVec(
|
||||
prometheus.HistogramOpts{
|
||||
Namespace: milvusNamespace,
|
||||
Subsystem: typeutil.ProxyRole,
|
||||
Name: "parse_expr_latency",
|
||||
Help: "the latency of parse expression",
|
||||
Buckets: buckets,
|
||||
}, []string{nodeIDLabelName, functionLabelName, statusLabelName})
|
||||
)
|
||||
|
||||
// RegisterProxy registers Proxy metrics
|
||||
|
@ -491,6 +500,8 @@ func RegisterProxy(registry *prometheus.Registry) {
|
|||
|
||||
registry.MustRegister(ProxySearchSparseNumNonZeros)
|
||||
|
||||
registry.MustRegister(ProxyParseExpressionLatency)
|
||||
|
||||
RegisterStreamingServiceClient(registry)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue