@@ -38,7 +38,9 @@ func (c *Client) discover(ctx context.Context) (string, string, error) {
3838 c .markConnected (addr , "" )
3939 return addr , "" , nil
4040 }
41- errorlog .Record ("prometheus" , "error" , "manual Prometheus URL %s not reachable" , addr )
41+ if ! discoveryDiagnosticsSuppressed (ctx ) {
42+ errorlog .Record ("prometheus" , "error" , "manual Prometheus URL %s not reachable" , addr )
43+ }
4244 return "" , "" , fmt .Errorf ("manual Prometheus URL %s not reachable" , addr )
4345 }
4446
@@ -67,7 +69,9 @@ func (c *Client) discover(ctx context.Context) (string, string, error) {
6769 log .Printf ("[prometheus] Discover error: %v" , err )
6870 }
6971 if len (candidates ) == 0 {
70- errorlog .Record ("prometheus" , "warning" , "no Prometheus service found in cluster" )
72+ if ! discoveryDiagnosticsSuppressed (ctx ) {
73+ errorlog .Record ("prometheus" , "warning" , "no Prometheus service found in cluster" )
74+ }
7175 return "" , "" , fmt .Errorf ("no Prometheus service found in cluster" )
7276 }
7377
@@ -99,7 +103,9 @@ func (c *Client) discover(ctx context.Context) (string, string, error) {
99103 connInfo , pfErr := portforward .Start (ctx , cand .Namespace , cand .Name , cand .TargetPort , contextName )
100104 if pfErr != nil {
101105 lastErr = fmt .Errorf ("port-forward to %s/%s failed: %w" , cand .Namespace , cand .Name , pfErr )
102- errorlog .Record ("prometheus" , "error" , "port-forward to %s/%s failed: %v" , cand .Namespace , cand .Name , pfErr )
106+ if ! discoveryDiagnosticsSuppressed (ctx ) {
107+ errorlog .Record ("prometheus" , "error" , "port-forward to %s/%s failed: %v" , cand .Namespace , cand .Name , pfErr )
108+ }
103109 continue
104110 }
105111
@@ -111,7 +117,9 @@ func (c *Client) discover(ctx context.Context) (string, string, error) {
111117
112118 portforward .Stop ()
113119 lastErr = fmt .Errorf ("Prometheus at %s/%s not responding after port-forward" , cand .Namespace , cand .Name )
114- errorlog .Record ("prometheus" , "error" , "Prometheus at %s/%s not responding after port-forward" , cand .Namespace , cand .Name )
120+ if ! discoveryDiagnosticsSuppressed (ctx ) {
121+ errorlog .Record ("prometheus" , "error" , "Prometheus at %s/%s not responding after port-forward" , cand .Namespace , cand .Name )
122+ }
115123 }
116124
117125 c .mu .Lock ()
0 commit comments