Commit 2b0a4131 authored by Michael Kozono's avatar Michael Kozono

Merge branch 'drop-db_load_balancing_index' into 'master'

Drop db_load_balancing_index gauge metric

See merge request gitlab-org/gitlab!17561
parents f730136c 0f091cd4
......@@ -140,8 +140,7 @@ The following metrics are available:
| 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_index` | Gauge | [12.3](https://gitlab.com/gitlab-org/gitlab/issues/13630) | Current load balancing host index |
| `db_load_balancing_hosts` | Gauge | [12.3](https://gitlab.com/gitlab-org/gitlab/issues/13630) | Current number of load balancing hosts |
## Ruby metrics
......
---
title: Remove db_load_balancing_index gauge metric
merge_request: 17561
author:
type: removed
......@@ -11,7 +11,6 @@ module Gitlab
@index = 0
@mutex = Mutex.new
@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!
end
......@@ -71,7 +70,6 @@ module Gitlab
def set_metrics!
@hosts_gauge.set({}, @hosts.length)
@index_gauge.set({}, @index)
end
end
end
......
require 'spec_helper'
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_index).get({})).to eq(index)
end
before do
......@@ -26,7 +25,7 @@ describe Gitlab::Database::LoadBalancing::HostList do
it 'sets metrics for current number of hosts and current index' do
host_list
expect_metrics(2, 0)
expect_metrics(2)
end
end
......@@ -76,7 +75,7 @@ describe Gitlab::Database::LoadBalancing::HostList do
expect(host_list.length).to eq(1)
expect(host_list.hosts[0].host).to eq('foo')
expect_metrics(1, 0)
expect_metrics(1)
end
end
......@@ -88,20 +87,20 @@ describe Gitlab::Database::LoadBalancing::HostList do
it 'cycles through all available hosts' do
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_metrics(2, 0)
expect_metrics(2)
expect(host_list.next).to eq(host_list.hosts[0])
expect_metrics(2, 1)
expect_metrics(2)
end
it 'skips hosts that are offline' do
allow(host_list.hosts[0]).to receive(:online?).and_return(false)
expect(host_list.next).to eq(host_list.hosts[1])
expect_metrics(2, 0)
expect_metrics(2)
end
it 'returns nil if no hosts are online' do
......@@ -110,7 +109,7 @@ describe Gitlab::Database::LoadBalancing::HostList do
end
expect(host_list.next).to be_nil
expect_metrics(2, 0)
expect_metrics(2)
end
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