Handle reporting errors gracefully for various metrics reporters
Change-Id: Ifc928fa25732609ff185caf213467ee40bdb6f53
diff --git a/apps/influxdbmetrics/src/main/java/org/onosproject/influxdbmetrics/DefaultInfluxDbMetricsReporter.java b/apps/influxdbmetrics/src/main/java/org/onosproject/influxdbmetrics/DefaultInfluxDbMetricsReporter.java
index 7ff636c..a0dca3b 100644
--- a/apps/influxdbmetrics/src/main/java/org/onosproject/influxdbmetrics/DefaultInfluxDbMetricsReporter.java
+++ b/apps/influxdbmetrics/src/main/java/org/onosproject/influxdbmetrics/DefaultInfluxDbMetricsReporter.java
@@ -120,7 +120,12 @@
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 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.");
}