public Metric(Locator locator, Object metricValue, long collectionTime, TimeValue ttl, String unit) {
this.locator = locator;
this.metricValue = metricValue;
// I dislike throwing errors in constructors, but there is no other way without resorting to a json schema.
if (collectionTime < 0) {
throw new InvalidDataException("collection time must be greater than zero");
}
this.collectionTime = collectionTime;
this.dataType = DataType.getMetricType(metricValue);
this.unit = unit;