Skip to content

Commit 86fac41

Browse files
authored
fix metric exporter mq connection issue (#2925)
1 parent 33846a5 commit 86fac41

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

mq/publishers.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,10 @@ func PushMetricsToExporter(metrics models.Metrics) error {
195195
if err != nil {
196196
return errors.New("failed to marshal metrics: " + err.Error())
197197
}
198-
if token := mqclient.Publish("metrics_exporter", 2, true, data); !token.WaitTimeout(MQ_TIMEOUT*time.Second) || token.Error() != nil {
198+
if mqclient == nil || !mqclient.IsConnectionOpen() {
199+
return errors.New("cannot publish ... mqclient not connected")
200+
}
201+
if token := mqclient.Publish("metrics_exporter", 0, true, data); !token.WaitTimeout(MQ_TIMEOUT*time.Second) || token.Error() != nil {
199202
var err error
200203
if token.Error() == nil {
201204
err = errors.New("connection timeout")

0 commit comments

Comments
 (0)