mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-01-07 19:31:51 +08:00
enhance: [Cherry-Pick] Fix some access log bugs (#30496)
pr: https://github.com/milvus-io/milvus/pull/30409 https://github.com/milvus-io/milvus/pull/29680 --------- Signed-off-by: aoiasd <zhicheng.yue@zilliz.com>
This commit is contained in:
parent
cea5396c33
commit
ad4a53d225
@ -30,6 +30,7 @@ import (
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
"github.com/milvus-io/milvus-proto/go-api/v2/commonpb"
|
||||
"github.com/milvus-io/milvus-proto/go-api/v2/milvuspb"
|
||||
"github.com/milvus-io/milvus/internal/proxy/connection"
|
||||
"github.com/milvus-io/milvus/pkg/util/merr"
|
||||
"github.com/milvus-io/milvus/pkg/util/paramtable"
|
||||
@ -165,11 +166,11 @@ func getMethodStatus(i *GrpcAccessInfo) string {
|
||||
return fmt.Sprintf("Grpc%s", code.String())
|
||||
}
|
||||
|
||||
if i.status.GetCode() != 0 {
|
||||
if i.status.GetCode() != 0 || i.err != nil {
|
||||
return "Failed"
|
||||
}
|
||||
|
||||
return code.String()
|
||||
return "Successful"
|
||||
}
|
||||
|
||||
func getUserName(i *GrpcAccessInfo) string {
|
||||
@ -268,10 +269,15 @@ func getExpr(i *GrpcAccessInfo) string {
|
||||
|
||||
func getSdkVersion(i *GrpcAccessInfo) string {
|
||||
clientInfo := connection.GetManager().Get(i.ctx)
|
||||
if clientInfo == nil {
|
||||
return unknownString
|
||||
if clientInfo != nil {
|
||||
return clientInfo.SdkType + "-" + clientInfo.SdkVersion
|
||||
}
|
||||
return clientInfo.SdkType + "-" + clientInfo.SdkVersion
|
||||
|
||||
if req, ok := i.req.(*milvuspb.ConnectRequest); ok {
|
||||
return req.ClientInfo.SdkType + "-" + req.ClientInfo.SdkVersion
|
||||
}
|
||||
|
||||
return unknownString
|
||||
}
|
||||
|
||||
func getClusterPrefix(i *GrpcAccessInfo) string {
|
||||
|
||||
@ -113,22 +113,29 @@ func (s *GrpcAccessInfoSuite) TestDbName() {
|
||||
|
||||
func (s *GrpcAccessInfoSuite) TestSdkInfo() {
|
||||
ctx := context.Background()
|
||||
clientInfo := &commonpb.ClientInfo{
|
||||
SdkType: "test",
|
||||
SdkVersion: "1.0",
|
||||
}
|
||||
|
||||
s.info.ctx = ctx
|
||||
result := s.info.Get("$sdk_version")
|
||||
s.Equal(unknownString, result[0])
|
||||
|
||||
s.info.req = &milvuspb.ConnectRequest{
|
||||
ClientInfo: clientInfo,
|
||||
}
|
||||
result = s.info.Get("$sdk_version")
|
||||
s.Equal(clientInfo.SdkType+"-"+clientInfo.SdkVersion, result[0])
|
||||
|
||||
identifier := 11111
|
||||
md := metadata.MD{util.IdentifierKey: []string{fmt.Sprint(identifier)}}
|
||||
ctx = metadata.NewIncomingContext(ctx, md)
|
||||
info := &commonpb.ClientInfo{
|
||||
SdkType: "test",
|
||||
SdkVersion: "1.0",
|
||||
}
|
||||
connection.GetManager().Register(ctx, int64(identifier), info)
|
||||
connection.GetManager().Register(ctx, int64(identifier), clientInfo)
|
||||
|
||||
s.info.ctx = ctx
|
||||
result = s.info.Get("$sdk_version")
|
||||
s.Equal(info.SdkType+"-"+info.SdkVersion, result[0])
|
||||
s.Equal(clientInfo.SdkType+"-"+clientInfo.SdkVersion, result[0])
|
||||
}
|
||||
|
||||
func (s *GrpcAccessInfoSuite) TestExpression() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user