From 1b06d6af958dc07febafc83a6f9e1876548c970c Mon Sep 17 00:00:00 2001 From: Louis-Philippe Huberdeau Date: Wed, 20 Jul 2022 12:02:22 -0400 Subject: [PATCH] Replace self=1 for self=lb when using loadbalancer --- config.go | 4 +++- exporter_test.go | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/config.go b/config.go index 04a5b98..2e8af54 100644 --- a/config.go +++ b/config.go @@ -263,7 +263,9 @@ func isCapEnabled(config rabbitExporterConfig, cap rabbitCapability) bool { } func selfLabel(config rabbitExporterConfig, isSelf bool) string { - if config.RabbitConnection == "loadbalancer" || isSelf { + if config.RabbitConnection == "loadbalancer" { + return "lb" + } else if isSelf { return "1" } else { return "0" diff --git a/exporter_test.go b/exporter_test.go index 86e960c..7a0719b 100644 --- a/exporter_test.go +++ b/exporter_test.go @@ -427,7 +427,7 @@ func TestResetMetricsOnRabbitFailure(t *testing.T) { t.Run("RabbitMQ is using loadbalancer -> self is always 1", func(t *testing.T) { rabbitUP = true rabbitQueuesUp = true - config.RabbitConnection = "loadbalaner" + config.RabbitConnection = "loadbalancer" req, _ := http.NewRequest("GET", "", nil) w := httptest.NewRecorder() promhttp.Handler().ServeHTTP(w, req) @@ -438,7 +438,7 @@ func TestResetMetricsOnRabbitFailure(t *testing.T) { t.Log(body) // queue - expectSubstring(t, body, `rabbitmq_queue_messages_ready{cluster="my-rabbit@ae74c041248b",durable="true",policy="ha-2",queue="myQueue2",self="1",vhost="/"} 25`) + expectSubstring(t, body, `rabbitmq_queue_messages_ready{cluster="my-rabbit@ae74c041248b",durable="true",policy="ha-2",queue="myQueue2",self="lb",vhost="/"} 25`) }) }