Search in sources :

Example 11 with MonitorElementInstance

use of com.creditease.monitor.captureframework.spi.MonitorElementInstance in project uavstack by uavorg.

the class ClientRespTimeCapHandler method doCap.

@Override
public void doCap(MonitorElement elem, CaptureContext context) {
    MonitorElementInstance inst = null;
    if (CaptureConstants.MOELEM_CLIENT_RESPTIME.equals(elem.getMonitorElemId())) {
        String clientRequestURL = (String) context.get(CaptureConstants.INFO_CLIENT_REQUEST_URL);
        String appid = (String) context.get(CaptureConstants.INFO_CLIENT_APPID);
        if (StringHelper.isEmpty(clientRequestURL) || appid == null) {
            return;
        }
        /**
         * rewrite client address if localhost or 127.0.0.1
         */
        clientRequestURL = MonitorServerUtil.rewriteURLForLocalHost(clientRequestURL);
        /**
         * rewrite httpUrl, remove relativeUrl and PathParam
         */
        if (clientRequestURL.indexOf("http") == 0) {
            clientRequestURL = rewriteHttpUrl(clientRequestURL);
        }
        if (null == clientRequestURL) {
            return;
        }
        String clientId = MonitorServerUtil.getServerHostPort() + "#" + appid + "#" + clientRequestURL;
        inst = elem.getInstance(clientId);
        /**
         * do client profiling
         */
        doProfileClient(context, clientRequestURL, appid);
    }
    recordCounters(context, inst);
}
Also used : MonitorElementInstance(com.creditease.monitor.captureframework.spi.MonitorElementInstance)

Example 12 with MonitorElementInstance

use of com.creditease.monitor.captureframework.spi.MonitorElementInstance in project uavstack by uavorg.

the class NoHttpServiceRespTimeCapHandler method doCap.

@Override
public void doCap(MonitorElement elem, CaptureContext context) {
    String urlInfo = (String) context.get(CaptureConstants.INFO_APPSERVER_CONNECTOR_REQUEST_URL);
    if (urlInfo == null) {
        return;
    }
    MonitorElementInstance inst = null;
    if (CaptureConstants.MOELEM_SERVER_RESPTIME_URL.equals(elem.getMonitorElemId())) {
        inst = elem.getInstance(urlInfo);
    }
    recordCounters(context, inst);
}
Also used : MonitorElementInstance(com.creditease.monitor.captureframework.spi.MonitorElementInstance)

Example 13 with MonitorElementInstance

use of com.creditease.monitor.captureframework.spi.MonitorElementInstance in project uavstack by uavorg.

the class JVMStateCapHandler method doCap.

@Override
public void doCap(MonitorElement elem, CaptureContext context) {
    if (CaptureConstants.MOELEM_JVMSTATE.equals(elem.getMonitorElemId())) {
        Integer port = (Integer) UAVServer.instance().getServerInfo(CaptureConstants.INFO_APPSERVER_LISTEN_PORT);
        String serverJVMid = "http://" + NetworkHelper.getLocalIP() + ":" + port;
        MonitorElementInstance instance = elem.getInstance(serverJVMid);
        // heap
        readHeapUsage(instance);
        // no heap
        readNonHeapUsage(instance);
        // thread
        readThreadUsage(instance);
        // heap & code mem pool
        readHeapPoolUsage(instance);
        // gc
        readGCUsage(instance);
        // classes usage
        readClassLoadUsage(instance);
        // cpu
        readCPUUsage(instance);
        // read customized metrics
        readCustomizedMetrics(instance);
    }
}
Also used : MonitorElementInstance(com.creditease.monitor.captureframework.spi.MonitorElementInstance)

Example 14 with MonitorElementInstance

use of com.creditease.monitor.captureframework.spi.MonitorElementInstance in project uavstack by uavorg.

the class ServerEndRespTimeCapHandler method doCap.

@Override
public void doCap(MonitorElement elem, CaptureContext context) {
    if (elem == null || context == null) {
        return;
    }
    MonitorElementInstance inst = null;
    String urlInfo = (String) context.get(CaptureConstants.INFO_APPSERVER_CONNECTOR_REQUEST_URL);
    if (urlInfo == null) {
        return;
    }
    /**
     * For none http service
     */
    if (urlInfo.startsWith("http") == false) {
        // as preCap is done by ServerEndRespTimeCapHandler, only doCap is need
        noHttpServRespHandler.doCap(elem, context);
        return;
    }
    /**
     * For application server http service
     */
    if (serverAddress == null) {
        String localPort = context.get(CaptureConstants.INFO_APPSERVER_CONNECTOR_LISTENPORT).toString();
        String localIP = NetworkHelper.getLocalIP();
        serverAddress = localIP + ":" + localPort;
    }
    String[] infos = rewriteServerAddress(urlInfo);
    if (infos == null) {
        return;
    }
    if (CaptureConstants.MOELEM_SERVER_RESPTIME_SYSTEM.equals(elem.getMonitorElemId())) {
        String appContext = (String) context.get(CaptureConstants.INFO_APPSERVER_CONNECTOR_CONTEXT);
        if (!StringHelper.isEmpty(appContext) && "/com.creditease.uav".equalsIgnoreCase(appContext)) {
            return;
        }
        inst = elem.getInstance(infos[1]);
    } else if (CaptureConstants.MOELEM_SERVER_RESPTIME_URL.equals(elem.getMonitorElemId())) {
        String urlId = infos[2];
        /**
         * NOTE: page need iplink profiling, then we can find out users
         */
        if (MonitorServerUtil.isIncludeMonitorURLForService(urlId) == false && MonitorServerUtil.isIncludeMonitorURLForPage(urlId) == false) {
            return;
        }
        String appContext = (String) context.get(CaptureConstants.INFO_APPSERVER_CONNECTOR_CONTEXT);
        String realpath = (String) context.get(CaptureConstants.INFO_APPSERVER_CONNECTOR_CONTEXT_REALPATH);
        String appId = MonitorServerUtil.getApplicationId(appContext, realpath);
        if (appContext != null || realpath != null) {
            /**
             * NOTE: as the internal application, we will not monitor it
             */
            if ("com.creditease.uav".equalsIgnoreCase(appId)) {
                return;
            }
            doProfileIPLink(context, appId, urlId);
        }
        if (needMonitor(appId, infos) == false) {
            return;
        }
        urlId = infos[2];
        inst = elem.getInstance(urlId);
    } else if (CaptureConstants.MOELEM_SERVER_RESPTIME_APP.equals(elem.getMonitorElemId())) {
        String appContext = (String) context.get(CaptureConstants.INFO_APPSERVER_CONNECTOR_CONTEXT);
        String realpath = (String) context.get(CaptureConstants.INFO_APPSERVER_CONNECTOR_CONTEXT_REALPATH);
        if (appContext == null) {
            return;
        }
        appContext = (appContext.equalsIgnoreCase("")) ? "" : appContext.substring(1);
        String appurl = infos[1] + "/" + appContext;
        String appId = MonitorServerUtil.getApplicationId(appContext, realpath);
        /**
         * NOTE: as the internal application, we will not monitor it
         */
        if ("com.creditease.uav".equalsIgnoreCase(appId)) {
            return;
        }
        String appuuId = appurl + "---" + appId;
        inst = elem.getInstance(appuuId);
    }
    if (MonitorUrlFilterMgr.getInstance().isMatchingUrlByType(ListType.SERVERURL_IGNORELIST, infos[3]) == true && MonitorUrlFilterMgr.getInstance().isMatchingUrlByType(ListType.SERVERURL_WHITELIST, infos[3]) == false) {
        // if in Ignorelist and not in whitelist, do not collect
        return;
    }
    recordCounters(context, inst);
}
Also used : MonitorElementInstance(com.creditease.monitor.captureframework.spi.MonitorElementInstance)

Example 15 with MonitorElementInstance

use of com.creditease.monitor.captureframework.spi.MonitorElementInstance in project uavstack by uavorg.

the class StandardMonitorElement method getInstance.

@Override
public MonitorElementInstance getInstance(String instanceId) {
    if (instanceId == null)
        return null;
    MonitorElementInstance instance = instances.get(instanceId);
    if (instance == null) {
        synchronized (instances) {
            instance = instances.get(instanceId);
            if (instance == null) {
                instance = new StandardMonitorElementInstance(instanceId, this);
                this.instances.put(instanceId, instance);
            }
        }
    }
    return instance;
}
Also used : MonitorElementInstance(com.creditease.monitor.captureframework.spi.MonitorElementInstance)

Aggregations

MonitorElementInstance (com.creditease.monitor.captureframework.spi.MonitorElementInstance)16 DataSource (javax.sql.DataSource)4 DruidDataSource (com.alibaba.druid.pool.DruidDataSource)1 StandardMonitorRepository (com.creditease.monitor.captureframework.repository.StandardMonitorRepository)1 MonitorElemCapHandler (com.creditease.monitor.captureframework.spi.MonitorElemCapHandler)1 MonitorElement (com.creditease.monitor.captureframework.spi.MonitorElement)1 MonitorRepository (com.creditease.monitor.captureframework.spi.MonitorRepository)1 ComboPooledDataSource (com.mchange.v2.c3p0.ComboPooledDataSource)1 Set (java.util.Set)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1