()
| 1947 | } |
| 1948 | |
| 1949 | func instanceID() string { |
| 1950 | h, err := os.Hostname() |
| 1951 | if err != nil { |
| 1952 | h = strconv.Itoa(os.Getpid()) |
| 1953 | } |
| 1954 | if metadata.OnGCE() { |
| 1955 | return getGCEInstanceID(h) |
| 1956 | } |
| 1957 | return h |
| 1958 | } |
| 1959 | |
| 1960 | func getGCEInstanceID(hostname string) string { |
| 1961 | instanceID, err := metadata.InstanceIDWithContext(context.Background()) |
no test coverage detected