public static final long MINIMUM_INTERVAL = MeasurementSchedule.MINIMUM_INTERVAL;
public static List<MeasurementDefinition> parseMetricsMetadata(MetricDescriptor metricDescriptor,
ResourceType resourceType) {
MeasurementDefinition definition;
DataType dataType = DataType.valueOf(metricDescriptor.getDataType().toUpperCase());
DisplayType displayType = DisplayType.valueOf(metricDescriptor.getDisplayType().toUpperCase());
long collectionInterval = MINUTE_30;
MeasurementUnits units = getMeasurementUnits(metricDescriptor.getUnits(), dataType);
switch (dataType) {
case MEASUREMENT: {
switch (resourceType.getCategory()) {
case PLATFORM: {
collectionInterval = MINUTE_10;
break;
}
case SERVER: {
collectionInterval = MINUTE_10;
break;
}
case SERVICE: {
collectionInterval = MINUTE_20;
break;
}
}
if (displayType != DisplayType.SUMMARY) {
collectionInterval *= 2;
}
break;
}
case TRAIT: {
collectionInterval = HOUR_24; // BZ 741331 no difference between summary and detail
break;
}
case CALLTIME: {
collectionInterval = MINUTE_10;
if (units != MeasurementUnits.MILLISECONDS) {
throw new IllegalStateException("Units must always be set to 'milliseconds' for call-time metrics.");
}
break;
}
default: {
throw new IllegalStateException("Unsupported metric data type: " + dataType);
}
}
collectionInterval = Math.max(MINIMUM_INTERVAL,
(metricDescriptor.getDefaultInterval() == null) ? collectionInterval : metricDescriptor
.getDefaultInterval().longValue());
definition = new MeasurementDefinition(metricDescriptor.getProperty(),
MeasurementCategory.valueOf(metricDescriptor.getCategory().toUpperCase()), getMeasurementUnits(
metricDescriptor.getUnits(), dataType), dataType, NumericType.valueOf(metricDescriptor
.getMeasurementType().toUpperCase()), metricDescriptor.isDefaultOn(), collectionInterval, displayType);
if (metricDescriptor.getDisplayName() != null) {
definition.setDisplayName(metricDescriptor.getDisplayName());
} else {
definition.setDisplayName(StringUtils.deCamelCase(definition.getName()));
}
if (metricDescriptor.getDescription() != null) {
definition.setDescription(metricDescriptor.getDescription());
} else {
definition.setDescription(definition.getDisplayName());
}
definition.setDestinationType(metricDescriptor.getDestinationType());
// Make sure that all summary properties are on by default.
// It is assumed that if a plugin developer marks a metric as "summary" (which
// shows the metric's graph within the graph page of the UI) then he doesn't want
// to show an empty graph by default. Therefore, a summary metric will always be
// enabled by default. You can't say a metric is a "summary" metric but with
// defaultOn="false". The defaultOn will be overridden here and will be set to true.
if (definition.getDisplayType() == DisplayType.SUMMARY) {
definition.setDefaultOn(true);
}
if ((definition.getNumericType() == NumericType.TRENDSUP)
|| (definition.getNumericType() == NumericType.TRENDSDOWN)) {
ArrayList<MeasurementDefinition> definitions = new ArrayList<MeasurementDefinition>();
MeasurementDefinition perMinuteMetric = new MeasurementDefinition(definition);
// Disable the raw metric since that is usually what the user will want. Typically,
// the user will only care about the per-minute metric.
definition.setDisplayType(DisplayType.DETAIL);
definition.setDefaultOn(false);
perMinuteMetric.setDisplayName(perMinuteMetric.getDisplayName() + " per Minute");
// This keeps track of whether the associated raw metric is TRENDUP or TRENDSDOWN.
perMinuteMetric.setRawNumericType(definition.getNumericType());
// The per-minute metric is no longer monotonically increasing/decreasing, but swinging within some band.
perMinuteMetric.setNumericType(NumericType.DYNAMIC);
definitions.add(definition);
definitions.add(perMinuteMetric);
return definitions;
} else {