mirror of
https://github.com/prometheus/prometheus.git
synced 2025-01-12 22:37:27 -08:00
code review
Signed-off-by: Marcin Skalski <skalskimarcin33@gmail.com>
This commit is contained in:
parent
48934aaef3
commit
e27232614a
|
@ -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
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue