Search in sources :

Example 26 with InterceptContext

use of com.creditease.monitor.interceptframework.spi.InterceptContext in project uavstack by uavorg.

the class GlobalFilter method inteceptResponse.

private void inteceptResponse(InterceptSupport iSupport, InterceptContext context) {
    InterceptContext respContext = iSupport.createInterceptContext(Event.GLOBAL_FILTER_RESPONSE);
    respContext.putAll(context.getAll());
    iSupport.doIntercept(respContext);
}
Also used : InterceptContext(com.creditease.monitor.interceptframework.spi.InterceptContext)

Example 27 with InterceptContext

use of com.creditease.monitor.interceptframework.spi.InterceptContext in project uavstack by uavorg.

the class WebServiceListenerIT method obtainWsInfo.

public void obtainWsInfo(Object address, Object impl) {
    InterceptContext ic = InterceptSupport.instance().getThreadLocalContext(Event.WEBCONTAINER_STARTED);
    @SuppressWarnings("unchecked") List<WebServiceProfileInfo> list = (ArrayList<WebServiceProfileInfo>) ic.get("webservice.profile.info");
    if (null == list) {
        list = new ArrayList<WebServiceProfileInfo>();
        ic.put("webservice.profile.info", list);
    }
    setWsInfo(list, address, impl);
}
Also used : InterceptContext(com.creditease.monitor.interceptframework.spi.InterceptContext) ArrayList(java.util.ArrayList) WebServiceProfileInfo(com.creditease.uav.profiling.handlers.webservice.WebServiceProfileInfo)

Example 28 with InterceptContext

use of com.creditease.monitor.interceptframework.spi.InterceptContext in project uavstack by uavorg.

the class HookFactory method stopHook.

/**
 * stop application framework hook
 *
 * @param webapploader
 * @param proxyClass
 * @param cntx
 */
public void stopHook(ClassLoader webapploader, String proxyClass, HookContext cntx, boolean shouldRemove) {
    try {
        if (log.isLogEnabled()) {
            log.info("STOP hookproxy[" + proxyClass + "] ");
        }
        InterceptContext context = (InterceptContext) cntx.get(HookConstants.INTERCEPTCONTEXT);
        String contextPath = (String) context.get(InterceptConstants.CONTEXTPATH);
        String proxyKey = getHookProxyKey(contextPath, proxyClass);
        HookProxy proxy = (!shouldRemove) ? hooks.get(proxyKey) : hooks.remove(proxyKey);
        if (proxy == null) {
            if (log.isDebugable()) {
                log.debug("no hookproxy[" + proxyClass + "] should be STOP", null);
            }
            return;
        }
        // run stop hookproxy
        proxy.stop(cntx, webapploader);
        if (log.isDebugable()) {
            log.debug("STOP hookproxy[" + proxyClass + "]  END", null);
        }
    } catch (Exception e) {
        log.error("STOP hookproxy[" + proxyClass + "] FAIL. ", e);
        return;
    }
}
Also used : InterceptContext(com.creditease.monitor.interceptframework.spi.InterceptContext)

Example 29 with InterceptContext

use of com.creditease.monitor.interceptframework.spi.InterceptContext in project uavstack by uavorg.

the class MSCPProfileHandler method doProfiling.

@Override
public void doProfiling(ProfileElement elem, ProfileContext context) {
    UAVServer.ServerVendor sv = (UAVServer.ServerVendor) UAVServer.instance().getServerInfo(CaptureConstants.INFO_APPSERVER_VENDOR);
    // only support MSCP Application
    if (sv != UAVServer.ServerVendor.MSCP) {
        return;
    }
    if (!ProfileConstants.PROELEM_COMPONENT.equals(elem.getElemId())) {
        return;
    }
    InterceptContext ic = context.get(InterceptContext.class);
    if (ic == null) {
        this.logger.warn("Profile:Annotation FAILs as No InterceptContext available", null);
        return;
    }
    /**
     * 1. get webappclassloader
     */
    ClassLoader webappclsLoader = (ClassLoader) ic.get(InterceptConstants.WEBAPPLOADER);
    if (null == webappclsLoader) {
        this.logger.warn("Profile:JARS FAILs as No webappclsLoader available", null);
        return;
    }
    Collection<ClassLoader> clList = ConfigurationManager.getInstance().getFeatureClassLoader();
    clList.add(webappclsLoader);
    ClassLoader[] allcl = new ClassLoader[clList.size()];
    allcl = clList.toArray(allcl);
    /**
     * 2. see what kind of components we could get via annotations or interface or parentClass
     */
    FastClasspathScanner fcs = new FastClasspathScanner(allcl, "com.creditease.uav", "com.creditease.agent", "org.uavstack");
    fcs.scan();
    /**
     * 3. get MSCPServlets profile info
     */
    InterceptContext itContext = context.get(InterceptContext.class);
    String appRootPath = (String) itContext.get(InterceptConstants.BASEPATH);
    String appName = (String) itContext.get(InterceptConstants.APPNAME);
    for (String componentClassName : componentClassMap.keySet()) {
        // set the instance id = simple name of the annotation class
        ProfileElementInstance inst = elem.getInstance(componentClassName);
        ComponentProcessor cp = componentClassMap.get(componentClassName);
        cp.handle(componentClassName, appName, inst, fcs);
    }
    /**
     * 4. load application info
     */
    loadAppInfo(elem, appRootPath, appName);
}
Also used : ProfileElementInstance(com.creditease.uav.profiling.spi.ProfileElementInstance) InterceptContext(com.creditease.monitor.interceptframework.spi.InterceptContext) FastClasspathScanner(io.github.lukehutch.fastclasspathscanner.FastClasspathScanner) UAVServer(com.creditease.monitor.UAVServer)

Example 30 with InterceptContext

use of com.creditease.monitor.interceptframework.spi.InterceptContext in project uavstack by uavorg.

the class MSCPPlusIT method onAppStart.

/**
 * onAppStart
 *
 * @param args
 */
public void onAppStart() {
    // String featureName = (String) args[0];
    IConfigurationManager cm = ConfigurationManager.getInstance();
    InterceptSupport iSupport = InterceptSupport.instance();
    InterceptContext context = iSupport.createInterceptContext(Event.WEBCONTAINER_STARTED);
    context.put(InterceptConstants.WEBAPPLOADER, this.getClass().getClassLoader());
    context.put(InterceptConstants.WEBWORKDIR, cm.getContext(IConfigurationManager.ROOT));
    context.put(InterceptConstants.CONTEXTPATH, "");
    context.put(InterceptConstants.APPNAME, cm.getContext(IConfigurationManager.NODEAPPID));
    context.put(InterceptConstants.BASEPATH, "/" + cm.getContext(IConfigurationManager.NODEAPPID));
    iSupport.doIntercept(context);
}
Also used : InterceptContext(com.creditease.monitor.interceptframework.spi.InterceptContext) InterceptSupport(com.creditease.monitor.interceptframework.InterceptSupport) IConfigurationManager(com.creditease.agent.spi.IConfigurationManager)

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