String formatted = MeasurementConverter.format(value, MeasurementUnits.MINUTES);
builder.append(formatted).append("]");
break;
case THRESHOLD:
MeasurementUnits units = condition.getMeasurementDefinition().getUnits();
formattedThreshold = MeasurementConverter.format(condition.getThreshold(), units, true);
if (condition.getOption() == null) {
builder.append("Metric Value Threshold [")
.append(condition.getName())
.append(" ")
.append(condition.getComparator())
.append(" ")
.append(formattedThreshold)
.append("]");
} else {
// this is a calltime threshold condition
builder.append("Call Time Value Threshold [");
if (condition.getMeasurementDefinition() != null) {
builder.append(condition.getMeasurementDefinition().getDisplayName()).append(" ");
}
builder.append(condition.getOption()) // MIN, MAX, AVG (never null)
.append(" ")
.append(condition.getComparator()) // <, >, =
.append(" ")
.append(formattedThreshold)
.append("]");
if (condition.getName() != null && condition.getName().length() > 0) {
builder.append(" with call destination matching '")
.append(condition.getName())
.append("'");
}
}
break;
case BASELINE:
formattedThreshold = MeasurementConverter.format(condition.getThreshold(),
MeasurementUnits.PERCENTAGE, true);
builder.append("Metric Value Baseline [")
.append(condition.getName())
.append(" ")
.append(condition.getComparator())
.append(" ")
.append(formattedThreshold)
.append(" of ")
.append(condition.getOption())
.append("]");
break;
case CHANGE:
if (condition.getOption() == null) {
builder.append("Metric Value Change [")
.append(condition.getName())
.append(" ")
.append("]");
} else {
// this is a calltime change condition
formattedThreshold = MeasurementConverter.format(condition.getThreshold(),
MeasurementUnits.PERCENTAGE, true);
builder.append("Call Time Value Changes [");
if (condition.getMeasurementDefinition() != null) {
builder.append(condition.getMeasurementDefinition().getDisplayName()).append(" ");
}
builder.append(condition.getOption()) // MIN, MAX, AVG (never null)
.append(" ")
.append(getCalltimeChangeComparator(condition.getComparator()))
.append(" by at least ")
.append(formattedThreshold)
.append("]");
if (condition.getName() != null && condition.getName().length() > 0) {
builder.append(" with call destination matching '")
.append(condition.getName())
.append("'");
}
}
break;
case TRAIT:
builder.append("Trait Change [")
.append(condition.getName())
.append("]");
if (condition.getOption() != null && condition.getOption().length() > 0) {
builder.append(" with trait value matching '")
.append(condition.getOption())
.append("'");
}
break;
case CONTROL:
builder.append("Operation Execution [")
.append(condition.getName())
.append("] with result status [")
.append(condition.getOption())
.append("]");
break;
case RESOURCE_CONFIG:
builder.append("Resource Configuration Change");
break;
case EVENT:
builder.append("Event Detection [")
.append(condition.getName())
.append("]");
if (condition.getOption() != null && condition.getOption().length() > 0) {
builder.append(" with event source matching '")
.append(condition.getOption())
.append("'");
}
break;
case DRIFT:
String configNameRegex = condition.getName();
String pathNameRegex = condition.getOption();
if (configNameRegex == null || configNameRegex.length() == 0) {
if (pathNameRegex == null || pathNameRegex.length() == 0) {
// neither a config name regex nor path regex was specified
builder.append("Drift Detection");
} else {
// a path name regex was specified, but not a config name regex
builder.append("Drift Detection for files that match \"")
.append(pathNameRegex)
.append("\"");
}
} else {
if (pathNameRegex == null || pathNameRegex.length() == 0) {
// a config name regex was specified, but not a path name regex
builder.append("Drift Detection for drift definition [")
.append(configNameRegex)
.append("]");
} else {
// both a config name regex and a path regex was specified
builder.append("Drift Detection for files that match \"")
.append(pathNameRegex)
.append("\" and for drift detection [")
.append(configNameRegex)
.append("]");
}
}
break;
case RANGE:
String metricName = condition.getName();
MeasurementUnits metricUnits = condition.getMeasurementDefinition().getUnits();
double loValue = condition.getThreshold();
String formattedLoValue = MeasurementConverter.format(loValue, metricUnits, true);
String formattedHiValue = condition.getOption();
try {
double hiValue = Double.parseDouble(formattedHiValue);