enhance: access log support print output fields of Query or Search (#30768)

Signed-off-by: aoiasd <zhicheng.yue@zilliz.com>
This commit is contained in:
aoiasd 2024-03-05 11:54:58 +08:00 committed by GitHub
parent 3b5ce73ded
commit 0dacf0172e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 21 additions and 0 deletions

View File

@ -49,6 +49,7 @@ var metricFuncMap = map[string]getMetricFunc{
"$time_start": getTimeStart,
"$time_end": getTimeEnd,
"$method_expr": getExpr,
"$output_fields": getOutputFields,
"$sdk_version": getSdkVersion,
"$cluster_prefix": getClusterPrefix,
}

View File

@ -302,3 +302,11 @@ func getSdkVersionByUserAgent(ctx context.Context) string {
func getClusterPrefix(i *GrpcAccessInfo) string {
return paramtable.Get().CommonCfg.ClusterPrefix.GetValue()
}
func getOutputFields(i *GrpcAccessInfo) string {
fields, ok := requestutil.GetOutputFieldsFromRequest(i.req)
if ok {
return fmt.Sprint(fields.([]string))
}
return unknownString
}

View File

@ -178,6 +178,18 @@ func (s *GrpcAccessInfoSuite) TestExpression() {
s.Equal(testExpr, result[0])
}
func (s *GrpcAccessInfoSuite) TestOutputFields() {
result := s.info.Get("$output_fields")
s.Equal(unknownString, result[0])
fileds := []string{"pk"}
s.info.req = &milvuspb.QueryRequest{
OutputFields: fileds,
}
result = s.info.Get("$output_fields")
s.Equal(fmt.Sprint(fileds), result[0])
}
func (s *GrpcAccessInfoSuite) TestClusterPrefix() {
cluster := "instance-test"
paramtable.Init()