code review

Signed-off-by: Marcin Skalski <skalskimarcin33@gmail.com>
This commit is contained in:
Marcin Skalski 2023-12-12 08:32:46 +01:00
parent 48934aaef3
commit e27232614a

View file

@ -178,11 +178,14 @@ func kumaMadsV1ResourceParser(resources []*anypb.Any, typeURL string) ([]model.L
func NewKumaHTTPDiscovery(conf *KumaSDConfig, logger log.Logger) (discovery.Discoverer, error) { func NewKumaHTTPDiscovery(conf *KumaSDConfig, logger log.Logger) (discovery.Discoverer, error) {
// Default to "prometheus" if hostname is unavailable. // Default to "prometheus" if hostname is unavailable.
var clientID string clientID := conf.ClientID
if conf.ClientID == "" { if clientID == "" {
clientID = defaultClientID(logger) var err error
} else { clientID, err = osutil.GetFQDN()
clientID = conf.ClientID if err != nil {
level.Debug(logger).Log("msg", "error getting FQDN", "err", err)
clientID = "prometheus"
}
} }
clientConfig := &HTTPResourceClientConfig{ clientConfig := &HTTPResourceClientConfig{
@ -216,12 +219,3 @@ func NewKumaHTTPDiscovery(conf *KumaSDConfig, logger log.Logger) (discovery.Disc
return d, nil return d, nil
} }
func defaultClientID(logger log.Logger) string {
clientID, err := osutil.GetFQDN()
if err != nil {
level.Debug(logger).Log("msg", "error getting FQDN", "err", err)
clientID = "prometheus"
}
return clientID
}