Commit 2a479268 authored by Toon Claes's avatar Toon Claes

Also log Prometheus metrics from the primary

Closes gitlab-org/gitlab-ee#5373.
parent be832e63
...@@ -7,9 +7,9 @@ module Geo ...@@ -7,9 +7,9 @@ module Geo
if Gitlab::Geo.primary? if Gitlab::Geo.primary?
fetch_secondary_geo_nodes_metrics fetch_secondary_geo_nodes_metrics
else
fetch_current_geo_node_metrics
end end
fetch_current_geo_node_metrics
end end
private private
......
---
title: Also log Geo Prometheus metrics from primary
merge_request: 5058
author:
type: added
...@@ -49,6 +49,22 @@ describe Geo::MetricsUpdateService, :geo do ...@@ -49,6 +49,22 @@ describe Geo::MetricsUpdateService, :geo do
} }
end end
let(:primary_data) do
{
success: true,
status_message: nil,
repositories_count: 10,
wikis_count: 10,
lfs_objects_count: 100,
job_artifacts_count: 100,
attachments_count: 30,
last_event_id: 2,
last_event_date: event_date,
event_log_count: 55,
event_log_max_id: 555
}
end
before do before do
allow(Gitlab::Metrics).to receive(:prometheus_metrics_enabled?).and_return(true) allow(Gitlab::Metrics).to receive(:prometheus_metrics_enabled?).and_return(true)
end end
...@@ -77,16 +93,19 @@ describe Geo::MetricsUpdateService, :geo do ...@@ -77,16 +93,19 @@ describe Geo::MetricsUpdateService, :geo do
end end
it 'attempts to retrieve metrics from all nodes' do it 'attempts to retrieve metrics from all nodes' do
allow(GeoNodeStatus).to receive(:current_node_status).and_return(GeoNodeStatus.from_json(primary_data.as_json))
subject.execute subject.execute
expect(Gitlab::Metrics.registry.get(:geo_db_replication_lag_seconds).values.count).to eq(2) expect(Gitlab::Metrics.registry.get(:geo_db_replication_lag_seconds).values.count).to eq(2)
expect(Gitlab::Metrics.registry.get(:geo_repositories).values.count).to eq(2) expect(Gitlab::Metrics.registry.get(:geo_repositories).values.count).to eq(3)
expect(Gitlab::Metrics.registry.get(:geo_repositories).get({ url: secondary.url })).to eq(10)
expect(Gitlab::Metrics.registry.get(:geo_repositories).get({ url: secondary.url })).to eq(10) expect(Gitlab::Metrics.registry.get(:geo_repositories).get({ url: secondary.url })).to eq(10)
expect(Gitlab::Metrics.registry.get(:geo_repositories).get({ url: another_secondary.url })).to eq(10)
expect(Gitlab::Metrics.registry.get(:geo_repositories).get({ url: primary.url })).to eq(10)
end end
it 'updates the GeoNodeStatus entry' do it 'updates the GeoNodeStatus entry' do
expect { subject.execute }.to change { GeoNodeStatus.count }.by(2) expect { subject.execute }.to change { GeoNodeStatus.count }.by(3)
status = secondary.status.load_data_from_current_node status = secondary.status.load_data_from_current_node
...@@ -97,7 +116,7 @@ describe Geo::MetricsUpdateService, :geo do ...@@ -97,7 +116,7 @@ describe Geo::MetricsUpdateService, :geo do
it 'updates only the active node' do it 'updates only the active node' do
secondary.update_attributes(enabled: false) secondary.update_attributes(enabled: false)
expect { subject.execute }.to change { GeoNodeStatus.count }.by(1) expect { subject.execute }.to change { GeoNodeStatus.count }.by(2)
expect(another_secondary.status).not_to be_nil expect(another_secondary.status).not_to be_nil
end end
......
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