in oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profiling/continuous/ContinuousProfilingMutationService.java [112:154]
private String validatePolicyItem(ContinuousProfilingPolicyItemCreation item) {
String timeWindowsValidate = validatePolicyItemWindows(item);
if (StringUtil.isNotEmpty(timeWindowsValidate)) {
return timeWindowsValidate;
}
try {
switch (item.getType()) {
case PROCESS_CPU:
final int cpuPercent = Integer.parseInt(item.getThreshold());
if (cpuPercent < 0 || cpuPercent > 100) {
return "the process CPU percent should in [0-100]";
}
break;
case PROCESS_THREAD_COUNT:
final int threadCount = Integer.parseInt(item.getThreshold());
if (threadCount < 0) {
return "the process thread count must bigger than zero";
}
break;
case SYSTEM_LOAD:
final int systemLoad = Integer.parseInt(item.getThreshold());
if (systemLoad < 0) {
return "the system load must bigger than zero";
}
break;
case HTTP_ERROR_RATE:
final int httpErrorRate = Integer.parseInt(item.getThreshold());
if (httpErrorRate < 0 || httpErrorRate > 100) {
return "the HTTP error rate should in [0-100]";
}
break;
case HTTP_AVG_RESPONSE_TIME:
final int httpAvgResponseTime = Integer.parseInt(item.getThreshold());
if (httpAvgResponseTime < 0) {
return "the HTTP average response time must bigger than zero";
}
break;
}
} catch (NumberFormatException e) {
return "parsing threshold error";
}
return null;
}