From b195fd4ecb7611a47a2b6bdce5bb49d1a2ccebf9 Mon Sep 17 00:00:00 2001 From: Conor Broderick Date: Mon, 10 Jul 2017 17:14:06 +0100 Subject: [PATCH] Log tcp errors (#188) --- tcp.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tcp.go b/tcp.go index 3a1ac2f..d823f42 100644 --- a/tcp.go +++ b/tcp.go @@ -32,11 +32,13 @@ func dialTCP(target string, module Module, registry *prometheus.Registry) (net.C targetAddress, port, err := net.SplitHostPort(target) if err != nil { + log.Errorf("Error splitting target address and port: %v", err) return nil, err } ip, err := chooseProtocol(module.TCP.PreferredIPProtocol, targetAddress, registry) if err != nil { + log.Errorf("Error choosing protocol: %v", err) return nil, err } @@ -52,6 +54,7 @@ func dialTCP(target string, module Module, registry *prometheus.Registry) (net.C } tlsConfig, err := config.NewTLSConfig(&module.TCP.TLSConfig) if err != nil { + log.Errorf("Error creating TLS configuration: %v", err) return nil, err } return tls.DialWithDialer(dialer, dialProtocol, dialTarget, tlsConfig) @@ -66,6 +69,7 @@ func probeTCP(target string, module Module, registry *prometheus.Registry) bool deadline := time.Now().Add(module.Timeout) conn, err := dialTCP(target, module, registry) if err != nil { + log.Errorf("Error dialing TCP: %v", err) return false } defer conn.Close() @@ -74,6 +78,7 @@ func probeTCP(target string, module Module, registry *prometheus.Registry) bool // If a deadline cannot be set, better fail the probe by returning an error // now rather than blocking forever. if err := conn.SetDeadline(deadline); err != nil { + log.Errorf("Error setting deadline: %v", err) return false } if module.TCP.TLS { -- 2.25.1