GetHostname returns the system hostname
()
| 270 | |
| 271 | // GetHostname returns the system hostname |
| 272 | func (d *Detector) GetHostname() (string, error) { |
| 273 | ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) |
| 274 | defer cancel() |
| 275 | |
| 276 | info, err := host.InfoWithContext(ctx) |
| 277 | if err != nil { |
| 278 | d.logger.WithError(err).Warn("Failed to get hostname") |
| 279 | // Fallback to os.Hostname |
| 280 | return os.Hostname() |
| 281 | } |
| 282 | |
| 283 | return info.Hostname, nil |
| 284 | } |
| 285 | |
| 286 | // GetIPAddress gets the primary IP address using network interfaces |
| 287 | func (d *Detector) GetIPAddress() string { |
no outgoing calls
no test coverage detected