mirror of
https://gitee.com/huoyo/ko-time.git
synced 2025-12-06 16:58:26 +08:00
add discardRate in DefaultConfig
This commit is contained in:
parent
d6eb04f4e7
commit
b4f0e58d08
@ -16,6 +16,7 @@ public class DefaultConfig {
|
||||
private String logLanguage;
|
||||
private Boolean logEnable;
|
||||
private Double threshold;
|
||||
private Double discardRate;
|
||||
private String pointcut;
|
||||
private Boolean exceptionEnable;
|
||||
private Boolean paramAnalyse;
|
||||
@ -30,6 +31,14 @@ public class DefaultConfig {
|
||||
private String userName;
|
||||
private String password;
|
||||
|
||||
public Double getDiscardRate() {
|
||||
return discardRate;
|
||||
}
|
||||
|
||||
public void setDiscardRate(Double discardRate) {
|
||||
this.discardRate = discardRate;
|
||||
}
|
||||
|
||||
public Boolean getDataReset() {
|
||||
return dataReset;
|
||||
}
|
||||
|
||||
@ -74,6 +74,7 @@ public class LoadConfig {
|
||||
config.setContextPath(defaultConfig.getContextPath());
|
||||
config.setLanguage(defaultConfig.getLanguage() == null ? "chinese" : defaultConfig.getLanguage());
|
||||
config.setThreadNum(defaultConfig.getThreadNum() == null ? 2 : defaultConfig.getThreadNum());
|
||||
config.setDiscardRate(defaultConfig.getDiscardRate() == null ? 0.3 : defaultConfig.getDiscardRate());
|
||||
config.setAuthEnable(defaultConfig.getAuthEnable() == null ? false : defaultConfig.getAuthEnable());
|
||||
config.setParamAnalyse(defaultConfig.getParamAnalyse() == null ? true : defaultConfig.getParamAnalyse());
|
||||
config.setDataReset(defaultConfig.getDataReset() == null ? false : defaultConfig.getDataReset());
|
||||
|
||||
@ -150,6 +150,9 @@ public class DataBase implements GraphService {
|
||||
try {
|
||||
List<Map<String, Object>> query = DataBaseUtil.query(getWriteConnection(), KoSqlConstant.queryMethodRe, new Object[]{sourceMethodNode.getId() + targetMethodNode.getId()});
|
||||
if (query.size() > 0) {
|
||||
if (Math.random()<Context.getConfig().getDiscardRate()) {
|
||||
return null;
|
||||
}
|
||||
Map<String, Object> old = query.get(0);
|
||||
double oldAvg = (double)old.get("avg_run_time");
|
||||
double oldMax = (double)old.get("max_run_time");
|
||||
@ -215,6 +218,9 @@ public class DataBase implements GraphService {
|
||||
};
|
||||
DataBaseUtil.insert(getWriteConnection(), KoSqlConstant.addParamsAna, params);
|
||||
} else {
|
||||
if (Math.random()<Context.getConfig().getDiscardRate()) {
|
||||
return;
|
||||
}
|
||||
Map<String, Object> old = query.get(0);
|
||||
double oldAvg = (double)old.get("avg_run_time");
|
||||
double oldMax = (double)old.get("max_run_time");
|
||||
|
||||
@ -64,6 +64,9 @@ public class MemoryBase implements GraphService {
|
||||
if (paramValueMetricMap.containsKey(methodId)) {
|
||||
Map<String, ParamMetric> paramMetricMap = paramValueMetricMap.get(methodId);
|
||||
if (paramMetricMap.containsKey(paramsKey)) {
|
||||
if (Math.random()<Context.getConfig().getDiscardRate()) {
|
||||
return;
|
||||
}
|
||||
ParamMetric paramMetric = paramMetricMap.get(paramsKey);
|
||||
BigDecimal bg = BigDecimal.valueOf((paramMetric.getAvgRunTime() + v) / 2.0);
|
||||
double avg = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
@ -117,6 +120,9 @@ public class MemoryBase implements GraphService {
|
||||
methodRelations.put(methodRelation.getId(), methodRelation);
|
||||
return methodRelation;
|
||||
} else {
|
||||
if (Math.random()<Context.getConfig().getDiscardRate()) {
|
||||
return null;
|
||||
}
|
||||
BigDecimal bg = BigDecimal.valueOf((methodRelation.getAvgRunTime() + old.getAvgRunTime()) / 2.0);
|
||||
double avg = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
old.setAvgRunTime(avg);
|
||||
|
||||
@ -66,6 +66,9 @@ public class RedisBase implements GraphService {
|
||||
if (redisTemplate.hasKey(key)) {
|
||||
Map<String, JSONObject> paramMetricMap = query(key, Map.class);
|
||||
if (paramMetricMap.containsKey(paramsKey)) {
|
||||
if (Math.random()<Context.getConfig().getDiscardRate()) {
|
||||
return;
|
||||
}
|
||||
ParamMetric paramMetric = paramMetricMap.get(paramsKey).toJavaObject(ParamMetric.class);
|
||||
BigDecimal bg = BigDecimal.valueOf((paramMetric.getAvgRunTime() + v) / 2.0);
|
||||
double avg = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
@ -122,6 +125,9 @@ public class RedisBase implements GraphService {
|
||||
insert(key, methodRelation);
|
||||
return methodRelation;
|
||||
} else {
|
||||
if (Math.random()<Context.getConfig().getDiscardRate()) {
|
||||
return null;
|
||||
}
|
||||
BigDecimal bg = BigDecimal.valueOf((methodRelation.getAvgRunTime() + old.getAvgRunTime()) / 2.0);
|
||||
double avg = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
old.setAvgRunTime(avg);
|
||||
|
||||
@ -109,6 +109,13 @@
|
||||
"description": "red will appear if avgRunTime>threshold",
|
||||
"sourceType": "cn.langpy.kotime.config.DefaultConfig"
|
||||
},
|
||||
{
|
||||
"name": "ko-time.discardRate",
|
||||
"type": "java.lang.Double",
|
||||
"defaultValue": 0.3,
|
||||
"description": "data will be discard if Math.random()<discardRate",
|
||||
"sourceType": "cn.langpy.kotime.config.DefaultConfig"
|
||||
},
|
||||
{
|
||||
"name": "ko-time.auth-enable",
|
||||
"type": "java.lang.Boolean",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user