Resolve "Prometheus service page shows error"

This commit is contained in:
Jose Ivan Vargas Lopez 2017-10-12 09:58:36 +00:00 committed by Phil Hughes
parent ba90f023f0
commit b5ada8eadd
3 changed files with 18 additions and 5 deletions

View file

@ -81,7 +81,11 @@ export default class PrometheusMetrics {
loadActiveMetrics() { loadActiveMetrics() {
this.showMonitoringMetricsPanelState(PANEL_STATE.LOADING); this.showMonitoringMetricsPanelState(PANEL_STATE.LOADING);
backOff((next, stop) => { backOff((next, stop) => {
$.getJSON(this.activeMetricsEndpoint) $.ajax({
url: this.activeMetricsEndpoint,
dataType: 'json',
global: false,
})
.done((res) => { .done((res) => {
if (res && res.success) { if (res && res.success) {
stop(res); stop(res);

View file

@ -0,0 +1,5 @@
---
title: Fix flash errors showing up on a non configured prometheus integration
merge_request: 35652
author:
type: fixed

View file

@ -109,12 +109,16 @@ describe('PrometheusMetrics', () => {
it('should show loader animation while response is being loaded and hide it when request is complete', (done) => { it('should show loader animation while response is being loaded and hide it when request is complete', (done) => {
const deferred = $.Deferred(); const deferred = $.Deferred();
spyOn($, 'getJSON').and.returnValue(deferred.promise()); spyOn($, 'ajax').and.returnValue(deferred.promise());
prometheusMetrics.loadActiveMetrics(); prometheusMetrics.loadActiveMetrics();
expect(prometheusMetrics.$monitoredMetricsLoading.hasClass('hidden')).toBeFalsy(); expect(prometheusMetrics.$monitoredMetricsLoading.hasClass('hidden')).toBeFalsy();
expect($.getJSON).toHaveBeenCalledWith(prometheusMetrics.activeMetricsEndpoint); expect($.ajax).toHaveBeenCalledWith({
url: prometheusMetrics.activeMetricsEndpoint,
dataType: 'json',
global: false,
});
deferred.resolve({ data: metrics, success: true }); deferred.resolve({ data: metrics, success: true });
@ -126,7 +130,7 @@ describe('PrometheusMetrics', () => {
it('should show empty state if response failed to load', (done) => { it('should show empty state if response failed to load', (done) => {
const deferred = $.Deferred(); const deferred = $.Deferred();
spyOn($, 'getJSON').and.returnValue(deferred.promise()); spyOn($, 'ajax').and.returnValue(deferred.promise());
spyOn(prometheusMetrics, 'populateActiveMetrics'); spyOn(prometheusMetrics, 'populateActiveMetrics');
prometheusMetrics.loadActiveMetrics(); prometheusMetrics.loadActiveMetrics();
@ -142,7 +146,7 @@ describe('PrometheusMetrics', () => {
it('should populate metrics list once response is loaded', (done) => { it('should populate metrics list once response is loaded', (done) => {
const deferred = $.Deferred(); const deferred = $.Deferred();
spyOn($, 'getJSON').and.returnValue(deferred.promise()); spyOn($, 'ajax').and.returnValue(deferred.promise());
spyOn(prometheusMetrics, 'populateActiveMetrics'); spyOn(prometheusMetrics, 'populateActiveMetrics');
prometheusMetrics.loadActiveMetrics(); prometheusMetrics.loadActiveMetrics();