use of com.creditease.uav.hook.dubbo.interceptors.DubboIT 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