Search in sources :

Example 11 with InterceptContext

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);
}
Also used : InterceptContext(com.creditease.monitor.interceptframework.spi.InterceptContext)

Example 12 with InterceptContext

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;
}
Also used : InterceptContext(com.creditease.monitor.interceptframework.spi.InterceptContext) DubboServiceProfileInfo(com.creditease.uav.profiling.handlers.dubbo.DubboServiceProfileInfo) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 13 with InterceptContext

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);
}
Also used : InterceptContext(com.creditease.monitor.interceptframework.spi.InterceptContext)

Example 14 with InterceptContext

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);
}
Also used : InterceptContext(com.creditease.monitor.interceptframework.spi.InterceptContext)

Example 15 with InterceptContext

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();
}
Also used : DPMethod(com.creditease.uav.monitorframework.dproxy.bytecode.DPMethod) InterceptContext(com.creditease.monitor.interceptframework.spi.InterceptContext) DubboIT(com.creditease.uav.hook.dubbo.interceptors.DubboIT) DynamicProxyProcessor(com.creditease.uav.monitorframework.dproxy.DynamicProxyProcessor)

Aggregations

InterceptContext (com.creditease.monitor.interceptframework.spi.InterceptContext)66 InterceptSupport (com.creditease.monitor.interceptframework.InterceptSupport)28 ServletContext (javax.servlet.ServletContext)12 StandardContext (org.apache.catalina.core.StandardContext)12 Servlet (javax.servlet.Servlet)6 ProfileElementInstance (com.creditease.uav.profiling.spi.ProfileElementInstance)5 LinkedHashMap (java.util.LinkedHashMap)4 Map (java.util.Map)4 StandardWrapper (org.apache.catalina.core.StandardWrapper)4 WebappClassLoader (org.apache.catalina.loader.WebappClassLoader)4 UAVServer (com.creditease.monitor.UAVServer)3 Event (com.creditease.monitor.interceptframework.spi.InterceptContext.Event)3 DynamicProxyProcessor (com.creditease.uav.monitorframework.dproxy.DynamicProxyProcessor)3 DPMethod (com.creditease.uav.monitorframework.dproxy.bytecode.DPMethod)3 DubboServiceProfileInfo (com.creditease.uav.profiling.handlers.dubbo.DubboServiceProfileInfo)3 LogProfileInfo (com.creditease.uav.profiling.handlers.log.LogProfileInfo)3 HashMap (java.util.HashMap)3 LinkedList (java.util.LinkedList)3 ServletException (javax.servlet.ServletException)3 WebAppContext (org.eclipse.jetty.webapp.WebAppContext)3