DaanHoogland commented on a change in pull request #5588:
URL: https://github.com/apache/cloudstack/pull/5588#discussion_r782283993
##########
File path: server/src/main/java/com/cloud/server/StatsCollector.java
##########
@@ -564,11 +681,485 @@ protected Point creteInfluxDbPoint(Object metricsObject)
{
}
}
+ class DbCollector extends AbstractStatsCollector {
+ List<Double> loadHistory = new ArrayList<>();
+ DbCollector() {
+ dbStats.put(loadAvarages, loadHistory);
+ }
+ @Override
+ protected void runInContext() {
+ LOGGER.debug(String.format("%s is running...",
this.getClass().getSimpleName()));
+
+ try {
+ int lastUptime = (dbStats.containsKey(uptime) ? (Integer)
dbStats.get(uptime) : 0);
+ int lastQueries = (dbStats.containsKey(queries) ? (Integer)
dbStats.get(queries) : 0);
+ getDynamicDataFromDB();
+ int interval = (Integer) dbStats.get(uptime) - lastUptime;
+ int activity = (Integer) dbStats.get(queries) - lastQueries;
+ loadHistory.add(0, Double.valueOf(activity / interval));
+ int maxsize =
DATABASE_SERVER_LOAD_HISTORY_RETENTION_NUMBER.value();
+ while (loadHistory.size() > maxsize) {
+ loadHistory.remove(maxsize - 1);
+ }
+ } catch (Throwable e) {
+ // pokemon catch to make sure the thread stays running
+ LOGGER.error("db statistics collection failed due to " +
e.getLocalizedMessage());
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug("db statistics collection failed.", e);
+ }
Review comment:
I did this on purpose to only add the stack on debug level and not at
`error`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]