enhance: Add proxy.ginLogSkipPaths (#28945)

Fix #28944

/cc @xiaofan-luan

Signed-off-by: shaoyue.chen <shaoyue.chen@zilliz.com>
pull/29022/head
shaoyue 2023-12-06 10:26:35 +08:00 committed by GitHub
parent 5bac7f7897
commit 4a067a4c8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 1 deletions

View File

@ -198,6 +198,7 @@ proxy:
# Whether to produce gin logs.\n
# please adjust in embedded Milvus: false
ginLogging: true
ginLogSkipPaths: "/" # skipped url path for gin log split by comma
maxTaskNum: 1024 # max task number of proxy task queue
accessLog:
enable: true

View File

@ -173,7 +173,11 @@ func (s *Server) registerHTTPServer() {
func (s *Server) startHTTPServer(errChan chan error) {
defer s.wg.Done()
ginHandler := gin.Default()
ginHandler := gin.New()
ginLogger := gin.LoggerWithConfig(gin.LoggerConfig{
SkipPaths: proxy.Params.ProxyCfg.GinLogSkipPaths.GetAsStrings(),
})
ginHandler.Use(ginLogger, gin.Recovery())
ginHandler.Use(func(c *gin.Context) {
_, err := strconv.ParseBool(c.Request.Header.Get(httpserver.HTTPHeaderAllowInt64))
if err != nil {

View File

@ -915,6 +915,7 @@ type proxyConfig struct {
MaxShardNum ParamItem `refreshable:"true"`
MaxDimension ParamItem `refreshable:"true"`
GinLogging ParamItem `refreshable:"false"`
GinLogSkipPaths ParamItem `refreshable:"false"`
MaxUserNum ParamItem `refreshable:"true"`
MaxRoleNum ParamItem `refreshable:"true"`
MaxTaskNum ParamItem `refreshable:"false"`
@ -1044,6 +1045,15 @@ please adjust in embedded Milvus: false`,
}
p.GinLogging.Init(base.mgr)
p.GinLogSkipPaths = ParamItem{
Key: "proxy.ginLogSkipPaths",
Version: "2.3.0",
DefaultValue: "/",
Doc: "skip url path for gin log",
Export: true,
}
p.GinLogSkipPaths.Init(base.mgr)
p.MaxUserNum = ParamItem{
Key: "proxy.maxUserNum",
DefaultValue: "100",