diff --git a/src/toolkits/stats/init.go b/src/toolkits/stats/init.go index bf7dd36d3d890f71782a8c67ec1132fc0575ec66..9b74917d35293b0d4da922e9a24867b305b1973e 100644 --- a/src/toolkits/stats/init.go +++ b/src/toolkits/stats/init.go @@ -21,14 +21,14 @@ var ( ) func Init(prefix string, addr ...string) { + if len(addr) > 0 && addr[0] != "" { + //如果配置了 addr,使用 addr 参数 + PushUrl = addr[0] - if file.IsExist(path.Join(runner.Cwd, "etc", "address.yml")) { - //address.yml 存在,使用配置文件的地址 + } else if file.IsExist(path.Join(runner.Cwd, "etc", "address.yml")) { + //address.yml 存在,则使用配置文件的地址 port := address.GetHTTPPort("collector") PushUrl = fmt.Sprintf("http://127.0.0.1:%d/api/collector/push", port) - } else if len(addr) > 0 && addr[0] != "" { - // address.yml 不存在,使用 addr 参数 - PushUrl = addr[0] } Counter = NewCounter(prefix)