Skip to content

Commit

Permalink
MB-45118: Adjust eventing stats polling according to ns_server scrape…
Browse files Browse the repository at this point in the history
…Interval

Change-Id: I51057a1c477050be3f3d5a09353ed17a7f962df2
Reviewed-on: http://review.couchbase.org/c/eventing/+/149586
Reviewed-by: Srini Raman <srinivasan.raman@couchbase.com>
Tested-by: Jon Strabala <jon.strabala@couchbase.com>
  • Loading branch information
Vinayaka R Kamath committed Mar 25, 2021
1 parent 9eae0bf commit b6f076f
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion ui/eventing-ui/ui-current/eventing.js
Expand Up @@ -57,6 +57,7 @@ angular.module('eventing', [
self.disableEditButton = false;
self.appListStaleCount = 0;
self.statusPollMillis = 2000;
self.pollingCount = 0;
self.deployedStats = null;
self.annotationList = []

Expand Down Expand Up @@ -209,8 +210,18 @@ angular.module('eventing', [
fetchCpuCount();
}


// Fetch at the beginning of every cycle
if(self.pollingCount == 0)
fetchDeployedStats(statsConfig);
// Only does the fetch if we have one or more items deploying or deployed in the UI
fetchDeployedStats(statsConfig);
self.pollingCount += 1;
// Fetch DeployesdStats once every scrapeInterval/2 seconds
ApplicationService.server.getScrapeInterval().then(function(value){
if (self.pollingCount >= ((value * 1000) / (self.statusPollMillis * 2))) {
self.pollingCount = 0;
}
});

}).catch(function(errResponse) {
self.errorCode = errResponse && errResponse.status || 500;
Expand Down Expand Up @@ -2229,6 +2240,13 @@ angular.module('eventing', [
console.log("error getting insight", response);
return {};
});
},
getScrapeInterval: function() {
return $http.get("/settings/metrics/").then(
function(response){
return response.data.scrapeInterval ? response.data.scrapeInterval : 10;
}
)
}
},
convertBindingToConfig: function(bindings) {
Expand Down

0 comments on commit b6f076f

Please sign in to comment.