use of com.creditease.monitor.interceptframework.spi.InterceptContext in project uavstack by uavorg.
the class LogProfileHandler method doProfiling.
@Override
public void doProfiling(ProfileElement elem, ProfileContext context) {
if (!ProfileConstants.PROELEM_LOGS.equals(elem.getElemId())) {
return;
}
InterceptContext ic = context.get(InterceptContext.class);
if (ic == null) {
this.logger.warn("Profile:LOGS FAILs as No InterceptContext available", null);
return;
}
ClassLoader webappclsLoader = (ClassLoader) ic.get(InterceptConstants.WEBAPPLOADER);
if (null == webappclsLoader) {
this.logger.warn("Profile:LOGS FAILs as No webappclsLoader available", null);
return;
}
String appid = (String) ic.get(InterceptConstants.CONTEXTPATH);
if (appid == null) {
this.logger.warn("Profile:LOGS FAILs as No appid get", null);
return;
}
// Log Source 1: LogProfileInfo
profileFromLogProfileInfo(elem, ic, appid);
// Log Source 2: JAppLogs
profileFromJAppLogs(elem);
}
use of com.creditease.monitor.interceptframework.spi.InterceptContext in project uavstack by uavorg.
the class DubboProfileHandler method isDubboServiceImplCls.
/**
* check if the class is a dubboService's impl class.
*/
@SuppressWarnings("unchecked")
public static boolean isDubboServiceImplCls(String clsName, ProfileContext context) {
InterceptContext ic = context.get(InterceptContext.class);
Map<String, DubboServiceProfileInfo> list = (Map<String, DubboServiceProfileInfo>) ic.get(HookConstants.DUBBO_PROFILE_LIST);
if (list == null) {
return false;
}
for (DubboServiceProfileInfo dspi : list.values()) {
if (clsName.equals(dspi.getServiceImplClass())) {
return true;
}
}
return false;
}
use of com.creditease.monitor.interceptframework.spi.InterceptContext in project uavstack by uavorg.
the class HttpClient3HookProxy method InsertInterceptToClients.
public void InsertInterceptToClients(HookContext context, ClassLoader webapploader) {
if (isHookEventDone("InsertInterceptToClients")) {
return;
}
InterceptContext ic = (InterceptContext) context.get(HookConstants.INTERCEPTCONTEXT);
String contextPath = (String) ic.get(InterceptConstants.CONTEXTPATH);
String basePath = (String) ic.get(InterceptConstants.BASEPATH);
final String appid = MonitorServerUtil.getApplicationId(contextPath, basePath);
doInstallDProxy(webapploader, appid);
}
use of com.creditease.monitor.interceptframework.spi.InterceptContext in project uavstack by uavorg.
the class JaxWSHookProxy method insertIntercepter.
private void insertIntercepter(HookContext context, ClassLoader webapploader) {
if (isHookEventDone("InsertInterceptToClients")) {
return;
}
InterceptContext ic = (InterceptContext) context.get(HookConstants.INTERCEPTCONTEXT);
String contextPath = (String) ic.get(InterceptConstants.CONTEXTPATH);
String basePath = (String) ic.get(InterceptConstants.BASEPATH);
final String appid = MonitorServerUtil.getApplicationId(contextPath, basePath);
doInstallDProxy(webapploader, appid);
}
use of com.creditease.monitor.interceptframework.spi.InterceptContext in project uavstack by uavorg.
the class DubboHookProxy method InsertInterceptToClients.
private void InsertInterceptToClients(HookContext context, ClassLoader webapploader) {
if (isHookEventDone("InsertInterceptToClients")) {
return;
}
InterceptContext ic = (InterceptContext) context.get(HookConstants.INTERCEPTCONTEXT);
String contextPath = (String) ic.get(InterceptConstants.CONTEXTPATH);
String basePath = (String) ic.get(InterceptConstants.BASEPATH);
final String appid = MonitorServerUtil.getApplicationId(contextPath, basePath);
/**
* set the webapploader is the target classloader
*/
dpInstall.setTargetClassLoader(webapploader);
/**
* inject ServiceBean for profiling
*/
dpInstall.installProxy("com.alibaba.dubbo.config.spring.ServiceBean", new String[] { "com.creditease.uav.hook.dubbo.interceptors" }, new DynamicProxyProcessor() {
@Override
public void process(DPMethod m) throws Exception {
if ("onApplicationEvent".equals(m.getName())) {
dpInstall.defineLocalVal(m, "mObj", DubboIT.class);
m.insertAfter("{mObj=new DubboIT(\"" + appid + "\");mObj.doProfiling(new Object[]{this,$1});}");
}
}
}, false);
/**
* inject Dubbo's MonitorFilter to get Service & Consumer Perf Data
*/
dpInstall.installProxy("com.alibaba.dubbo.monitor.support.MonitorFilter", new String[] { "com.creditease.uav.hook.dubbo.interceptors" }, new DynamicProxyProcessor() {
@Override
public void process(DPMethod m) throws Exception {
if ("invoke".equals(m.getName())) {
dpInstall.defineLocalVal(m, "mObj", DubboIT.class);
m.insertBefore("{DubboIT.doMonitorStart(\"" + appid + "\",new Object[]{$1,$2},false,null);}");
m.insertAfter("{DubboIT.doMonitorEnd(new Object[]{$1,$2,$_},true,null);}");
dpInstall.addCatch(m, "{DubboIT.doMonitorEnd(new Object[]{$1,$2},true,$e);throw $e;}");
}
}
}, false);
// release loader
dpInstall.releaseTargetClassLoader();
}
Aggregations