private boolean shouldPersist(Metric metric) {
try {
final DataType metricType = metric.getDataType();
final MetricsPersistenceOptimizer optimizer =
MetricsPersistenceOptimizerFactory.getOptimizer(metricType);
return optimizer.shouldPersist(metric);
} catch (Exception e) {
// If we hit any exception, just persist the metric
return true;
}
}