|
|
@ -24,12 +24,16 @@ func Init(prefix string, addr ...string) {
|
|
|
|
if len(addr) > 0 && addr[0] != "" {
|
|
|
|
if len(addr) > 0 && addr[0] != "" {
|
|
|
|
//如果配置了 addr,使用 addr 参数
|
|
|
|
//如果配置了 addr,使用 addr 参数
|
|
|
|
PushUrl = addr[0]
|
|
|
|
PushUrl = addr[0]
|
|
|
|
|
|
|
|
|
|
|
|
} else if file.IsExist(path.Join(runner.Cwd, "etc", "address.yml")) {
|
|
|
|
} else if file.IsExist(path.Join(runner.Cwd, "etc", "address.yml")) {
|
|
|
|
//address.yml 存在,则使用配置文件的地址
|
|
|
|
//address.yml 存在,则使用配置文件的地址
|
|
|
|
newAddr := address.GetHTTPAddresses("collector")
|
|
|
|
newAddr := address.GetHTTPAddresses("collector")
|
|
|
|
|
|
|
|
if len(newAddr) == 0 {
|
|
|
|
|
|
|
|
port := address.GetHTTPPort("collector")
|
|
|
|
|
|
|
|
PushUrl = fmt.Sprintf("http://127.0.0.1:%d/api/collector/push", port)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
PushUrl = fmt.Sprintf("http://%s/api/collector/push", newAddr[0])
|
|
|
|
PushUrl = fmt.Sprintf("http://%s/api/collector/push", newAddr[0])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Counter = NewCounter(prefix)
|
|
|
|
Counter = NewCounter(prefix)
|
|
|
|
go Push()
|
|
|
|
go Push()
|
|
|
|