Przeglądaj źródła

fix metric exporter mq connection issue (#2925)

Max Ma 1 rok temu
rodzic
commit
86fac41868
1 zmienionych plików z 4 dodań i 1 usunięć
  1. 4 1
      mq/publishers.go

+ 4 - 1
mq/publishers.go

@@ -195,7 +195,10 @@ func PushMetricsToExporter(metrics models.Metrics) error {
 	if err != nil {
 		return errors.New("failed to marshal metrics: " + err.Error())
 	}
-	if token := mqclient.Publish("metrics_exporter", 2, true, data); !token.WaitTimeout(MQ_TIMEOUT*time.Second) || token.Error() != nil {
+	if mqclient == nil || !mqclient.IsConnectionOpen() {
+		return errors.New("cannot publish ... mqclient not connected")
+	}
+	if token := mqclient.Publish("metrics_exporter", 0, true, data); !token.WaitTimeout(MQ_TIMEOUT*time.Second) || token.Error() != nil {
 		var err error
 		if token.Error() == nil {
 			err = errors.New("connection timeout")