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) {
// Default to "prometheus" if hostname is unavailable.
var clientID string
if conf.ClientID == "" {
clientID = defaultClientID(logger)
} else {
clientID = conf.ClientID
clientID := conf.ClientID
if clientID == "" {
var err error
clientID, err = osutil.GetFQDN()
if err != nil {
level.Debug(logger).Log("msg", "error getting FQDN", "err", err)
clientID = "prometheus"
}
}
clientConfig := &HTTPResourceClientConfig{
@ -216,12 +219,3 @@ func NewKumaHTTPDiscovery(conf *KumaSDConfig, logger log.Logger) (discovery.Disc
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
}