Jian Li
Committed by Gerrit Code Review

Handle reporting errors gracefully for various metrics reporters

Change-Id: Ifc928fa25732609ff185caf213467ee40bdb6f53
......@@ -92,7 +92,7 @@ public class DefaultGangliaMetricsReporter implements GangliaMetricsReporter {
@Activate
public void activate() {
cfgService.registerProperties(getClass());
coreService.registerApplication("org.onosproject.metrics.reporter");
coreService.registerApplication("org.onosproject.gangliametrics");
metricsService.registerReporter(this);
startReport();
......@@ -120,7 +120,13 @@ public class DefaultGangliaMetricsReporter implements GangliaMetricsReporter {
public void startReport() {
configGMetric();
gangliaReporter = buildReporter(ganglia);
gangliaReporter.start(REPORT_PERIOD, REPORT_TIME_UNIT);
try {
gangliaReporter.start(REPORT_PERIOD, REPORT_TIME_UNIT);
} catch (Exception e) {
log.error("Errors during reporting to ganglia, msg: {}" + e.getMessage());
}
log.info("Start to report metrics to ganglia server.");
}
......@@ -142,7 +148,13 @@ public class DefaultGangliaMetricsReporter implements GangliaMetricsReporter {
public void notifyMetricsChange() {
gangliaReporter.stop();
gangliaReporter = buildReporter(ganglia);
gangliaReporter.start(REPORT_PERIOD, REPORT_TIME_UNIT);
try {
gangliaReporter.start(REPORT_PERIOD, REPORT_TIME_UNIT);
} catch (Exception e) {
log.error("Errors during reporting to ganglia, msg: {}" + e.getMessage());
}
log.info("Metric registry has been changed, apply changes.");
}
......
......@@ -125,7 +125,13 @@ public class DefaultGraphiteMetricsReporter implements GraphiteMetricsReporter {
public void startReport() {
configGraphite();
graphiteReporter = buildReporter(graphite);
graphiteReporter.start(reportPeriod, REPORT_TIME_UNIT);
try {
graphiteReporter.start(DEFAULT_REPORT_PERIOD, REPORT_TIME_UNIT);
} catch (Exception e) {
log.error("Errors during reporting to graphite, msg: {}" + e.getMessage());
}
log.info("Start to report metrics to graphite server.");
}
......@@ -146,7 +152,13 @@ public class DefaultGraphiteMetricsReporter implements GraphiteMetricsReporter {
public void notifyMetricsChange() {
graphiteReporter.stop();
graphiteReporter = buildReporter(graphite);
graphiteReporter.start(DEFAULT_REPORT_PERIOD, REPORT_TIME_UNIT);
try {
graphiteReporter.start(DEFAULT_REPORT_PERIOD, REPORT_TIME_UNIT);
} catch (Exception e) {
log.error("Errors during reporting to graphite, msg: {}" + e.getMessage());
}
log.info("Metric registry has been changed, apply changes.");
}
......
......@@ -120,7 +120,12 @@ public class DefaultInfluxDbMetricsReporter implements InfluxDbMetricsReporter {
public void startReport() {
configSender();
influxDbReporter = buildReporter(influxDbHttpSender);
influxDbReporter.start(REPORT_PERIOD, REPORT_TIME_UNIT);
try {
influxDbReporter.start(REPORT_PERIOD, REPORT_TIME_UNIT);
} catch (Exception e) {
log.error("Errors during reporting to InfluxDB, msg: {}" + e.getMessage());
}
log.info("Start to report metrics to influxDB.");
}
......@@ -142,7 +147,13 @@ public class DefaultInfluxDbMetricsReporter implements InfluxDbMetricsReporter {
public void notifyMetricsChange() {
influxDbReporter.stop();
influxDbReporter = buildReporter(influxDbHttpSender);
influxDbReporter.start(REPORT_PERIOD, REPORT_TIME_UNIT);
try {
influxDbReporter.start(REPORT_PERIOD, REPORT_TIME_UNIT);
} catch (Exception e) {
log.error("Errors during reporting to InfluxDB, msg: {}" + e.getMessage());
}
log.info("Metric registry has been changed, apply changes.");
}
......