Skip to content

Commit

Permalink
Merge pull request #293 from williamfzc/master
Browse files Browse the repository at this point in the history
通过环境变量支持自定义service name
  • Loading branch information
qiniu-bot authored Aug 5, 2022
2 parents 50b62f0 + bc5f609 commit fd3df3e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/cover/instrument.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,13 @@ func registerHandlers() {
}
func registerSelf(address string) ([]byte, error) {
selfName := filepath.Base(os.Args[0])
customServiceName, ok := os.LookupEnv("GOC_SERVICE_NAME")
var selfName string
if ok {
selfName = customServiceName
} else {
selfName = filepath.Base(os.Args[0])
}
req, err := http.NewRequest("POST", fmt.Sprintf("%s/v1/cover/register?name=%s&address=%s", {{.Center | printf "%q"}}, selfName, address), nil)
if err != nil {
log.Fatalf("http.NewRequest failed: %v", err)
Expand Down

0 comments on commit fd3df3e

Please sign in to comment.