Avoid printing full stacktrace in DefaultMetricsDatabase
Change-Id: I26e1e929add05f43bcb851d39709876975bac5d6
Showing
1 changed file
with
3 additions
and
3 deletions
... | @@ -45,7 +45,7 @@ import static com.google.common.base.Preconditions.checkNotNull; | ... | @@ -45,7 +45,7 @@ import static com.google.common.base.Preconditions.checkNotNull; |
45 | * An implementation of control plane metrics back-end database. | 45 | * An implementation of control plane metrics back-end database. |
46 | */ | 46 | */ |
47 | public final class DefaultMetricsDatabase implements MetricsDatabase { | 47 | public final class DefaultMetricsDatabase implements MetricsDatabase { |
48 | - private final Logger log = LoggerFactory.getLogger(getClass()); | 48 | + private static final Logger log = LoggerFactory.getLogger(DefaultMetricsDatabase.class); |
49 | 49 | ||
50 | private String metricName; | 50 | private String metricName; |
51 | private String resourceName; | 51 | private String resourceName; |
... | @@ -112,7 +112,7 @@ public final class DefaultMetricsDatabase implements MetricsDatabase { | ... | @@ -112,7 +112,7 @@ public final class DefaultMetricsDatabase implements MetricsDatabase { |
112 | checkArgument(rrdDb.containsDs(k), NON_EXIST_METRIC); | 112 | checkArgument(rrdDb.containsDs(k), NON_EXIST_METRIC); |
113 | sample.setValue(k, v); | 113 | sample.setValue(k, v); |
114 | } catch (IOException e) { | 114 | } catch (IOException e) { |
115 | - e.printStackTrace(); | 115 | + log.error("Failed to update metric value due to {}", e.getMessage()); |
116 | } | 116 | } |
117 | }); | 117 | }); |
118 | sample.update(); | 118 | sample.update(); |
... | @@ -317,7 +317,7 @@ public final class DefaultMetricsDatabase implements MetricsDatabase { | ... | @@ -317,7 +317,7 @@ public final class DefaultMetricsDatabase implements MetricsDatabase { |
317 | // always store the metric data in memory... | 317 | // always store the metric data in memory... |
318 | rrdDb = new RrdDb(rrdDef, RrdBackendFactory.getFactory(STORING_METHOD)); | 318 | rrdDb = new RrdDb(rrdDef, RrdBackendFactory.getFactory(STORING_METHOD)); |
319 | } catch (IOException e) { | 319 | } catch (IOException e) { |
320 | - e.printStackTrace(); | 320 | + log.warn("Failed to create a new round-robin database due to {}", e.getMessage()); |
321 | } | 321 | } |
322 | 322 | ||
323 | return new DefaultMetricsDatabase(metricName, resourceName, rrdDb); | 323 | return new DefaultMetricsDatabase(metricName, resourceName, rrdDb); | ... | ... |
-
Please register or login to post a comment