Loading ee/app/services/geo/metrics_update_service.rb +2 −2 Original line number Diff line number Diff line Loading @@ -7,9 +7,9 @@ def execute if Gitlab::Geo.primary? fetch_secondary_geo_nodes_metrics else fetch_current_geo_node_metrics end fetch_current_geo_node_metrics end private Loading ee/changelogs/unreleased/tc-geo-primary-prometheus.yml 0 → 100644 +5 −0 Original line number Diff line number Diff line --- title: Also log Geo Prometheus metrics from primary merge_request: 5058 author: type: added ee/spec/services/geo/metrics_update_service_spec.rb +23 −4 Original line number Diff line number Diff line Loading @@ -49,6 +49,22 @@ } 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 allow(Gitlab::Metrics).to receive(:prometheus_metrics_enabled?).and_return(true) end Loading Loading @@ -77,16 +93,19 @@ end 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 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).get({ url: secondary.url })).to eq(10) 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: another_secondary.url })).to eq(10) expect(Gitlab::Metrics.registry.get(:geo_repositories).get({ url: primary.url })).to eq(10) end 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 Loading @@ -97,7 +116,7 @@ it 'updates only the active node' do 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 end Loading Loading
ee/app/services/geo/metrics_update_service.rb +2 −2 Original line number Diff line number Diff line Loading @@ -7,9 +7,9 @@ def execute if Gitlab::Geo.primary? fetch_secondary_geo_nodes_metrics else fetch_current_geo_node_metrics end fetch_current_geo_node_metrics end private Loading
ee/changelogs/unreleased/tc-geo-primary-prometheus.yml 0 → 100644 +5 −0 Original line number Diff line number Diff line --- title: Also log Geo Prometheus metrics from primary merge_request: 5058 author: type: added
ee/spec/services/geo/metrics_update_service_spec.rb +23 −4 Original line number Diff line number Diff line Loading @@ -49,6 +49,22 @@ } 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 allow(Gitlab::Metrics).to receive(:prometheus_metrics_enabled?).and_return(true) end Loading Loading @@ -77,16 +93,19 @@ end 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 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).get({ url: secondary.url })).to eq(10) 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: another_secondary.url })).to eq(10) expect(Gitlab::Metrics.registry.get(:geo_repositories).get({ url: primary.url })).to eq(10) end 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 Loading @@ -97,7 +116,7 @@ it 'updates only the active node' do 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 end Loading