mirror of
https://gitee.com/huoyo/ko-time.git
synced 2025-12-08 01:38:26 +08:00
add a charger for param analysis
This commit is contained in:
parent
55aef2a659
commit
e6249fbeaa
@ -16,6 +16,7 @@ public class DefaultConfig {
|
|||||||
private Double threshold;
|
private Double threshold;
|
||||||
private String pointcut;
|
private String pointcut;
|
||||||
private Boolean exceptionEnable;
|
private Boolean exceptionEnable;
|
||||||
|
private Boolean paramAnalyse;
|
||||||
private String saveSaver;
|
private String saveSaver;
|
||||||
private Boolean saveAsync;
|
private Boolean saveAsync;
|
||||||
private Integer threadNum;
|
private Integer threadNum;
|
||||||
@ -127,4 +128,12 @@ public class DefaultConfig {
|
|||||||
public void setAuthEnable(Boolean authEnable) {
|
public void setAuthEnable(Boolean authEnable) {
|
||||||
this.authEnable = authEnable;
|
this.authEnable = authEnable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Boolean getParamAnalyse() {
|
||||||
|
return paramAnalyse;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParamAnalyse(Boolean paramAnalyse) {
|
||||||
|
this.paramAnalyse = paramAnalyse;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -58,6 +58,7 @@ public class LoadConfig {
|
|||||||
config.setEnable(defaultConfig.getEnable()==null?kotimeEnable:defaultConfig.getEnable());
|
config.setEnable(defaultConfig.getEnable()==null?kotimeEnable:defaultConfig.getEnable());
|
||||||
config.setContextPath(defaultConfig.getContextPath());
|
config.setContextPath(defaultConfig.getContextPath());
|
||||||
config.setAuthEnable(defaultConfig.getAuthEnable()==null?false:defaultConfig.getAuthEnable());
|
config.setAuthEnable(defaultConfig.getAuthEnable()==null?false:defaultConfig.getAuthEnable());
|
||||||
|
config.setParamAnalyse(defaultConfig.getParamAnalyse()==null?true:defaultConfig.getParamAnalyse());
|
||||||
Context.setConfig(config);
|
Context.setConfig(config);
|
||||||
log.info("kotime=>loading config");
|
log.info("kotime=>loading config");
|
||||||
|
|
||||||
|
|||||||
@ -58,7 +58,7 @@ public class MemoryBase implements GraphService {
|
|||||||
|
|
||||||
List<Class<?>> baseTypes = Arrays.asList(Integer.class, Double.class, Float.class, String.class, Boolean.class, MultipartFile.class);
|
List<Class<?>> baseTypes = Arrays.asList(Integer.class, Double.class, Float.class, String.class, Boolean.class, MultipartFile.class);
|
||||||
|
|
||||||
public void addMethodAnalyse(String methodId, Parameter[] names, Object[] values, double v) {
|
public void addParamAnalyse(String methodId, Parameter[] names, Object[] values, double v) {
|
||||||
List<String> params = new ArrayList<>();
|
List<String> params = new ArrayList<>();
|
||||||
for (int i = 0; i < names.length; i++) {
|
for (int i = 0; i < names.length; i++) {
|
||||||
Class<?> type = names[i].getType();
|
Class<?> type = names[i].getType();
|
||||||
|
|||||||
@ -18,7 +18,7 @@ public class MysqlBase implements GraphService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addMethodAnalyse(String methodId, Parameter[] names, Object[] values, double v) {
|
public void addParamAnalyse(String methodId, Parameter[] names, Object[] values, double v) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -54,7 +54,9 @@ public class RunTimeHandler implements MethodInterceptor {
|
|||||||
graphService.addMethodNode(parent);
|
graphService.addMethodNode(parent);
|
||||||
graphService.addMethodNode(current);
|
graphService.addMethodNode(current);
|
||||||
graphService.addMethodRelation(parent, current);
|
graphService.addMethodRelation(parent, current);
|
||||||
graphService.addMethodAnalyse(current.getId(),invocation.getMethod().getParameters(), invocation.getArguments(),((end - begin) / 1000000.0));
|
if (Context.getConfig().getParamAnalyse()) {
|
||||||
|
graphService.addParamAnalyse(current.getId(),invocation.getMethod().getParameters(), invocation.getArguments(),((end - begin) / 1000000.0));
|
||||||
|
}
|
||||||
MethodStack.clear();
|
MethodStack.clear();
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,7 +27,7 @@ public interface GraphService {
|
|||||||
|
|
||||||
void addMethodNode(MethodNode methodNode);
|
void addMethodNode(MethodNode methodNode);
|
||||||
|
|
||||||
void addMethodAnalyse(String methodId,Parameter[] names, Object[] values,double v);
|
void addParamAnalyse(String methodId, Parameter[] names, Object[] values, double v);
|
||||||
|
|
||||||
void addExceptionNode(ExceptionNode exceptionNode);
|
void addExceptionNode(ExceptionNode exceptionNode);
|
||||||
|
|
||||||
|
|||||||
@ -19,11 +19,14 @@ public class Common {
|
|||||||
public static String getRoute(MethodInvocation pjp) {
|
public static String getRoute(MethodInvocation pjp) {
|
||||||
Class<?> targetClass = pjp.getThis().getClass();
|
Class<?> targetClass = pjp.getThis().getClass();
|
||||||
String[] classRoute = getRouteValue(targetClass);
|
String[] classRoute = getRouteValue(targetClass);
|
||||||
if (classRoute == null || classRoute.length==0) {
|
if (classRoute == null || classRoute.length == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
StringBuilder routes = new StringBuilder(classRoute[0]);
|
StringBuilder routes = new StringBuilder(classRoute[0]);
|
||||||
String[] methodRoute = getRouteValue(pjp.getMethod());
|
String[] methodRoute = getRouteValue(pjp.getMethod());
|
||||||
|
if (methodRoute == null || methodRoute.length == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
if (methodRoute[0].startsWith("/")) {
|
if (methodRoute[0].startsWith("/")) {
|
||||||
routes.append(methodRoute[0]);
|
routes.append(methodRoute[0]);
|
||||||
} else {
|
} else {
|
||||||
@ -33,65 +36,51 @@ public class Common {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static String[] getRouteValue(Class<?> targetClass) {
|
private static String[] getRouteValue(Class<?> targetClass) {
|
||||||
String[] methodRoute = null;
|
|
||||||
RequestMapping methodAnnotationRequest = targetClass.getAnnotation(RequestMapping.class);
|
RequestMapping methodAnnotationRequest = targetClass.getAnnotation(RequestMapping.class);
|
||||||
if (methodAnnotationRequest == null) {
|
if (methodAnnotationRequest != null) {
|
||||||
PostMapping methodAnnotationPost = targetClass.getAnnotation(PostMapping.class);
|
return methodAnnotationRequest.value();
|
||||||
if (methodAnnotationPost == null) {
|
|
||||||
GetMapping methodAnnotationGet = targetClass.getAnnotation(GetMapping.class);
|
|
||||||
if (methodAnnotationGet == null) {
|
|
||||||
PutMapping methodAnnotationPut = targetClass.getAnnotation(PutMapping.class);
|
|
||||||
if (methodAnnotationPut == null) {
|
|
||||||
DeleteMapping methodAnnotationDelete = targetClass.getAnnotation(DeleteMapping.class);
|
|
||||||
if (methodAnnotationDelete == null) {
|
|
||||||
return null;
|
|
||||||
} else {
|
|
||||||
methodRoute = methodAnnotationDelete.value();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
methodRoute = methodAnnotationPut.value();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
methodRoute = methodAnnotationGet.value();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
methodRoute = methodAnnotationPost.value();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
methodRoute = methodAnnotationRequest.value();
|
|
||||||
}
|
}
|
||||||
return methodRoute;
|
PostMapping methodAnnotationPost = targetClass.getAnnotation(PostMapping.class);
|
||||||
|
if (methodAnnotationPost != null) {
|
||||||
|
return methodAnnotationPost.value();
|
||||||
|
}
|
||||||
|
GetMapping methodAnnotationGet = targetClass.getAnnotation(GetMapping.class);
|
||||||
|
if (methodAnnotationGet != null) {
|
||||||
|
return methodAnnotationGet.value();
|
||||||
|
}
|
||||||
|
PutMapping methodAnnotationPut = targetClass.getAnnotation(PutMapping.class);
|
||||||
|
if (methodAnnotationPut != null) {
|
||||||
|
return methodAnnotationPut.value();
|
||||||
|
}
|
||||||
|
DeleteMapping methodAnnotationDelete = targetClass.getAnnotation(DeleteMapping.class);
|
||||||
|
if (methodAnnotationDelete != null) {
|
||||||
|
return methodAnnotationDelete.value();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String[] getRouteValue(Method method) {
|
private static String[] getRouteValue(Method method) {
|
||||||
String[] methodRoute = null;
|
|
||||||
RequestMapping methodAnnotationRequest = method.getAnnotation(RequestMapping.class);
|
RequestMapping methodAnnotationRequest = method.getAnnotation(RequestMapping.class);
|
||||||
if (methodAnnotationRequest == null) {
|
if (methodAnnotationRequest != null) {
|
||||||
PostMapping methodAnnotationPost = method.getAnnotation(PostMapping.class);
|
return methodAnnotationRequest.value();
|
||||||
if (methodAnnotationPost == null) {
|
|
||||||
GetMapping methodAnnotationGet = method.getAnnotation(GetMapping.class);
|
|
||||||
if (methodAnnotationGet == null) {
|
|
||||||
PutMapping methodAnnotationPut = method.getAnnotation(PutMapping.class);
|
|
||||||
if (methodAnnotationPut == null) {
|
|
||||||
DeleteMapping methodAnnotationDelete = method.getAnnotation(DeleteMapping.class);
|
|
||||||
if (methodAnnotationDelete == null) {
|
|
||||||
return null;
|
|
||||||
} else {
|
|
||||||
methodRoute = methodAnnotationDelete.value();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
methodRoute = methodAnnotationPut.value();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
methodRoute = methodAnnotationGet.value();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
methodRoute = methodAnnotationPost.value();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
methodRoute = methodAnnotationRequest.value();
|
|
||||||
}
|
}
|
||||||
return methodRoute;
|
PostMapping methodAnnotationPost = method.getAnnotation(PostMapping.class);
|
||||||
|
if (methodAnnotationPost != null) {
|
||||||
|
return methodAnnotationPost.value();
|
||||||
|
}
|
||||||
|
GetMapping methodAnnotationGet = method.getAnnotation(GetMapping.class);
|
||||||
|
if (methodAnnotationGet != null) {
|
||||||
|
return methodAnnotationGet.value();
|
||||||
|
}
|
||||||
|
PutMapping methodAnnotationPut = method.getAnnotation(PutMapping.class);
|
||||||
|
if (methodAnnotationPut != null) {
|
||||||
|
return methodAnnotationPut.value();
|
||||||
|
}
|
||||||
|
DeleteMapping methodAnnotationDelete = method.getAnnotation(DeleteMapping.class);
|
||||||
|
if (methodAnnotationDelete != null) {
|
||||||
|
return methodAnnotationDelete.value();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MethodType getMethodType(MethodInvocation pjp) {
|
public static MethodType getMethodType(MethodInvocation pjp) {
|
||||||
|
|||||||
@ -97,6 +97,13 @@
|
|||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
"description": "password for authentication",
|
"description": "password for authentication",
|
||||||
"sourceType": "cn.langpy.kotime.config.DefaultConfig"
|
"sourceType": "cn.langpy.kotime.config.DefaultConfig"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ko-time.param-analyse",
|
||||||
|
"type": "java.lang.Boolean",
|
||||||
|
"defaultValue": true,
|
||||||
|
"description": "the charger of analysing params",
|
||||||
|
"sourceType": "cn.langpy.kotime.config.DefaultConfig"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"hints": []
|
"hints": []
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user