Skip to content

Commit

Permalink
Use fqdn when possible
Browse files Browse the repository at this point in the history
the svc.Node is not always fqdn, we want to use fqdn to ease intersection with other metrics
  • Loading branch information
geobeau committed Jul 12, 2022
1 parent a3a5dfc commit a399d5c
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions common/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ package common

import (
"fmt"
"sort"
"strings"

"github.com/hashicorp/consul/api"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
"sort"
"strings"
)

//TODO detect probe stuck
Expand Down Expand Up @@ -55,9 +56,14 @@ func DiscoverNodesForService(consul *api.Client, serviceName string) ([]Node, er
addr = svc.ServiceAddress
}

log.Debug("Service discovered: ", svc.Node, " (", addr, ":", svc.ServicePort, ")")
node_name := svc.Node
if fqdn, ok := svc.NodeMeta["fqdn"]; ok {
node_name = fqdn
}

log.Debug("Service discovered: ", node_name, " (", addr, ":", svc.ServicePort, ")")
nodeList = append(nodeList, Node{
Name: svc.Node,
Name: node_name,
Ip: addr,
Port: svc.ServicePort,
Scheme: schemeFromTags(svc.ServiceTags),
Expand Down

0 comments on commit a399d5c

Please sign in to comment.