Skip to content

Commit

Permalink
feat: track failed servers after attempting connecting
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Spaink committed Jul 13, 2022
1 parent b43d484 commit c741d79
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion plugins/outputs/graphite/graphite.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ func (g *Graphite) Connect() error {

// Get Connections
var conns []net.Conn
var failedServers []string
for _, server := range servers {
// Dialer with timeout
d := net.Dialer{Timeout: time.Duration(g.Timeout) * time.Second}
Expand All @@ -95,12 +96,15 @@ func (g *Graphite) Connect() error {

if err == nil {
conns = append(conns, conn)
} else {
g.Log.Debugf("Failed to establish connection: %v", err)
failedServers = append(failedServers, server)
}
}

if len(g.failedServers) > 0 {
g.conns = append(g.conns, conns...)
g.failedServers = []string{}
g.failedServers = failedServers
} else {
g.conns = conns
}
Expand Down

0 comments on commit c741d79

Please sign in to comment.