Search in sources :

Example 11 with ServerVendor

use of com.creditease.monitor.UAVServer.ServerVendor in project uavstack by uavorg.

the class GlobalFilterDispatchListener method handleEvent.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void handleEvent(InterceptContext context) {
    UAVServer.ServerVendor vendor = (ServerVendor) UAVServer.instance().getServerInfo(CaptureConstants.INFO_APPSERVER_VENDOR);
    Object httpReq = context.get(InterceptConstants.HTTPREQUEST);
    Object httpResp = context.get(InterceptConstants.HTTPRESPONSE);
    String url = null;
    /**
     * MSCP
     */
    if (vendor == ServerVendor.MSCP) {
    // TODO
    } else /**
     * JEE Application uses HttpServletRequest
     */
    {
        StringBuffer urlSB = (StringBuffer) ReflectionHelper.invoke("javax.servlet.http.HttpServletRequest", httpReq, "getRequestURL", null, null);
        if (urlSB != null) {
            url = urlSB.toString();
        }
    }
    if (url == null) {
        return;
    }
    if (MonitorServerUtil.isIncludeMonitorURL(url) == false) {
        return;
    }
    /**
     * NOTE: 目前的机制下,执行可能分为几种情况:
     *
     * 1. 执行1个BaseGlobalFilterHandler,就终止Handler Chain,也终止Filter
     * Chain,则该handler的isBlockHandlerChain和isBlockFilterChain都为true
     *
     * 2. 执行多个BaseGlobalFilterHandler(contextPath有重合或叠加),才终止Handler Chain,但不终止Filter
     * Chain,最后一个BaseGlobalFilterHandler的isBlockHandlerChain为true,
     * 所有的BaseGlobalFilterHandler的isBlockFilterChain为false
     *
     * 3. 执行多个BaseGlobalFilterHandler(contextPath有重合或叠加),才终止Handler Chain,,也终止Filter
     * Chain,最后一个BaseGlobalFilterHandler的isBlockHandlerChain为true,
     * 其中任何一个BaseGlobalFilterHandler的isBlockFilterChain为true
     *
     * 所以要注意,BaseGlobalFilterHandler的执行顺序与注册的顺序有关
     */
    boolean isBlockFilterChain = false;
    for (AbsGlobalFilterHandler handler : handlers) {
        String contextPath = handler.getContext();
        if (url.indexOf(contextPath) > -1) {
            try {
                handler.handle(httpReq, httpResp, context);
            } catch (Exception e) {
                logger.error("GlobalFilterDispatchListener Handler[" + handler.getClass().getName() + "] runs FAIL: url=" + url, e);
            }
            if (handler.isBlockFilterChain() == true) {
                isBlockFilterChain = true;
            }
            if (handler.isBlockHandlerChain() == true) {
                break;
            }
        }
    }
    if (isBlockFilterChain == true) {
        context.put(InterceptConstants.STOPREQUEST, new Object());
    }
}
Also used : ServerVendor(com.creditease.monitor.UAVServer.ServerVendor) ServerVendor(com.creditease.monitor.UAVServer.ServerVendor) UAVServer(com.creditease.monitor.UAVServer) AbsGlobalFilterHandler(com.creditease.monitor.globalfilter.AbsGlobalFilterHandler)

Example 12 with ServerVendor

use of com.creditease.monitor.UAVServer.ServerVendor in project uavstack by uavorg.

the class InterceptFrameworkSupportor method start.

@Override
public void start() {
    String listenersString = System.getProperty("com.creditease.uav.interceptlisteners");
    if (null == listenersString) {
        return;
    }
    String[] defaultListeners = listenersString.split(",");
    // Step 1: install intercept listeners
    InterceptSupport is = InterceptSupport.instance();
    for (String listenerClass : defaultListeners) {
        InterceptEventListener listener = is.createInterceptEventListener(listenerClass);
        if (listener != null) {
            if (this.logger.isLogEnabled()) {
                this.logger.info("InterceptEventListener[" + listenerClass + "] load SUCCESS");
            }
            is.addEventListener(listener);
        }
    }
    // Step 2: register UAVServerController
    ServerVendor vendor = (ServerVendor) UAVServer.instance().getServerInfo(CaptureConstants.INFO_APPSERVER_VENDOR);
    GlobalFilterDispatchListener listener = (GlobalFilterDispatchListener) InterceptSupport.instance().getEventListener(GlobalFilterDispatchListener.class);
    // MSCP
    if (vendor == ServerVendor.MSCP) {
    // TODO
    } else // JEE
    {
        listener.registerHandler(new UAVServerJEEController("UAVServerJEEController"));
    }
    // init MonitorUrlFilterMgr
    MonitorUrlFilterMgr.getInstance().init();
}
Also used : InterceptSupport(com.creditease.monitor.interceptframework.InterceptSupport) ServerVendor(com.creditease.monitor.UAVServer.ServerVendor) GlobalFilterDispatchListener(com.creditease.uav.appserver.listeners.GlobalFilterDispatchListener) UAVServerJEEController(com.creditease.monitor.globalfilter.jee.UAVServerJEEController) InterceptEventListener(com.creditease.monitor.interceptframework.spi.InterceptEventListener)

Example 13 with ServerVendor

use of com.creditease.monitor.UAVServer.ServerVendor in project uavstack by uavorg.

the class HttpJEEJVMObserver method doRequest.

@Override
protected void doRequest(HttpServletRequest request, HttpServletResponse response, InterceptContext ic) {
    String action = request.getParameter("action");
    if (action.equalsIgnoreCase("ping")) {
        ServerVendor sv = (UAVServer.ServerVendor) UAVServer.instance().getServerInfo(CaptureConstants.INFO_APPSERVER_VENDOR);
        this.writeResponseBody(response, sv.toString(), HttpServletResponse.SC_OK);
    } else if (action.equalsIgnoreCase("getSystemPro")) {
        System.setProperty("proc.ext.pid", JVMToolHelper.getCurrentProcId());
        this.writeResponseBody(response, JSONHelper.toString(System.getProperties()), HttpServletResponse.SC_OK);
    }
}
Also used : ServerVendor(com.creditease.monitor.UAVServer.ServerVendor)

Aggregations

ServerVendor (com.creditease.monitor.UAVServer.ServerVendor)13 GlobalFilterDispatchListener (com.creditease.uav.appserver.listeners.GlobalFilterDispatchListener)5 UAVServer (com.creditease.monitor.UAVServer)2 DynamicProxyProcessor (com.creditease.uav.monitorframework.dproxy.DynamicProxyProcessor)2 DPMethod (com.creditease.uav.monitorframework.dproxy.bytecode.DPMethod)2 HashMap (java.util.HashMap)2 AbsGlobalFilterHandler (com.creditease.monitor.globalfilter.AbsGlobalFilterHandler)1 UAVServerJEEController (com.creditease.monitor.globalfilter.jee.UAVServerJEEController)1 InterceptSupport (com.creditease.monitor.interceptframework.InterceptSupport)1 InterceptContext (com.creditease.monitor.interceptframework.spi.InterceptContext)1 InterceptEventListener (com.creditease.monitor.interceptframework.spi.InterceptEventListener)1 ClientSpanInvokeChainHandler (com.creditease.uav.apm.invokechain.handlers.ClientSpanInvokeChainHandler)1 MethodSpanInvokeChainHandler (com.creditease.uav.apm.invokechain.handlers.MethodSpanInvokeChainHandler)1 ServiceSpanInvokeChainHandler (com.creditease.uav.apm.invokechain.handlers.ServiceSpanInvokeChainHandler)1 JEEServiceRunGlobalFilterHandler (com.creditease.uav.apm.invokechain.jee.JEEServiceRunGlobalFilterHandler)1 JdbcDriverIT (com.creditease.uav.hook.jdbc.interceptors.JdbcDriverIT)1 Profile (com.creditease.uav.profiling.spi.Profile)1 ProfileElementInstance (com.creditease.uav.profiling.spi.ProfileElementInstance)1 FastClasspathScanner (io.github.lukehutch.fastclasspathscanner.FastClasspathScanner)1 IOException (java.io.IOException)1