Commit 0f091cd4 authored by Thong Kuah's avatar Thong Kuah Committed by Michael Kozono

Drop db_load_balancing_index gauge metric

As the host list is shuffled per rails process, this metric is
meaningless and should not be relied upon. So we are removing this
metric.
parent f730136c
...@@ -140,8 +140,7 @@ The following metrics are available: ...@@ -140,8 +140,7 @@ The following metrics are available:
| Metric | Type | Since | Description | | Metric | Type | Since | Description |
|:--------------------------------- |:--------- |:------------------------------------------------------------- |:-------------------------------------- | |:--------------------------------- |:--------- |:------------------------------------------------------------- |:-------------------------------------- |
| `db_load_balancing_hosts` | Gauge | [12.3](https://gitlab.com/gitlab-org/gitlab/issues/13630) | Current number of load balancing hosts | | `db_load_balancing_hosts` | Gauge | [12.3](https://gitlab.com/gitlab-org/gitlab/issues/13630) | Current number of load balancing hosts |
| `db_load_balancing_index` | Gauge | [12.3](https://gitlab.com/gitlab-org/gitlab/issues/13630) | Current load balancing host index |
## Ruby metrics ## Ruby metrics
......
---
title: Remove db_load_balancing_index gauge metric
merge_request: 17561
author:
type: removed
...@@ -11,7 +11,6 @@ module Gitlab ...@@ -11,7 +11,6 @@ module Gitlab
@index = 0 @index = 0
@mutex = Mutex.new @mutex = Mutex.new
@hosts_gauge = Gitlab::Metrics.gauge(:db_load_balancing_hosts, 'Current number of load balancing hosts') @hosts_gauge = Gitlab::Metrics.gauge(:db_load_balancing_hosts, 'Current number of load balancing hosts')
@index_gauge = Gitlab::Metrics.gauge(:db_load_balancing_index, 'Current load balancing host index')
set_metrics! set_metrics!
end end
...@@ -71,7 +70,6 @@ module Gitlab ...@@ -71,7 +70,6 @@ module Gitlab
def set_metrics! def set_metrics!
@hosts_gauge.set({}, @hosts.length) @hosts_gauge.set({}, @hosts.length)
@index_gauge.set({}, @index)
end end
end end
end end
......
require 'spec_helper' require 'spec_helper'
describe Gitlab::Database::LoadBalancing::HostList do describe Gitlab::Database::LoadBalancing::HostList do
def expect_metrics(hosts, index) def expect_metrics(hosts)
expect(Gitlab::Metrics.registry.get(:db_load_balancing_hosts).get({})).to eq(hosts) expect(Gitlab::Metrics.registry.get(:db_load_balancing_hosts).get({})).to eq(hosts)
expect(Gitlab::Metrics.registry.get(:db_load_balancing_index).get({})).to eq(index)
end end
before do before do
...@@ -26,7 +25,7 @@ describe Gitlab::Database::LoadBalancing::HostList do ...@@ -26,7 +25,7 @@ describe Gitlab::Database::LoadBalancing::HostList do
it 'sets metrics for current number of hosts and current index' do it 'sets metrics for current number of hosts and current index' do
host_list host_list
expect_metrics(2, 0) expect_metrics(2)
end end
end end
...@@ -76,7 +75,7 @@ describe Gitlab::Database::LoadBalancing::HostList do ...@@ -76,7 +75,7 @@ describe Gitlab::Database::LoadBalancing::HostList do
expect(host_list.length).to eq(1) expect(host_list.length).to eq(1)
expect(host_list.hosts[0].host).to eq('foo') expect(host_list.hosts[0].host).to eq('foo')
expect_metrics(1, 0) expect_metrics(1)
end end
end end
...@@ -88,20 +87,20 @@ describe Gitlab::Database::LoadBalancing::HostList do ...@@ -88,20 +87,20 @@ describe Gitlab::Database::LoadBalancing::HostList do
it 'cycles through all available hosts' do it 'cycles through all available hosts' do
expect(host_list.next).to eq(host_list.hosts[0]) expect(host_list.next).to eq(host_list.hosts[0])
expect_metrics(2, 1) expect_metrics(2)
expect(host_list.next).to eq(host_list.hosts[1]) expect(host_list.next).to eq(host_list.hosts[1])
expect_metrics(2, 0) expect_metrics(2)
expect(host_list.next).to eq(host_list.hosts[0]) expect(host_list.next).to eq(host_list.hosts[0])
expect_metrics(2, 1) expect_metrics(2)
end end
it 'skips hosts that are offline' do it 'skips hosts that are offline' do
allow(host_list.hosts[0]).to receive(:online?).and_return(false) allow(host_list.hosts[0]).to receive(:online?).and_return(false)
expect(host_list.next).to eq(host_list.hosts[1]) expect(host_list.next).to eq(host_list.hosts[1])
expect_metrics(2, 0) expect_metrics(2)
end end
it 'returns nil if no hosts are online' do it 'returns nil if no hosts are online' do
...@@ -110,7 +109,7 @@ describe Gitlab::Database::LoadBalancing::HostList do ...@@ -110,7 +109,7 @@ describe Gitlab::Database::LoadBalancing::HostList do
end end
expect(host_list.next).to be_nil expect(host_list.next).to be_nil
expect_metrics(2, 0) expect_metrics(2)
end end
it 'returns nil if no hosts are available' do it 'returns nil if no hosts are available' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment