Skip to content

Commit

Permalink
Replace self=1 for self=lb when using loadbalancer
Browse files Browse the repository at this point in the history
  • Loading branch information
Louis-Philippe Huberdeau committed Jul 20, 2022
1 parent d4a526c commit 1b06d6a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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`)
})

}
Expand Down

0 comments on commit 1b06d6a

Please sign in to comment.