Search in sources :

Example 1 with ProfileElementInstance

use of com.creditease.uav.profiling.spi.ProfileElementInstance in project uavstack by uavorg.

the class MSCPProfileHandler method loadAppInfo.

/**
 * load application info
 *
 * @param elem
 * @param featureRootPath
 * @param featureName
 */
private void loadAppInfo(ProfileElement elem, String featureRootPath, String appName) {
    ProfileElementInstance inst = elem.getInstance("webapp");
    String nodeAppName = ConfigurationManager.getInstance().getContext(IConfigurationManager.NODEAPPNAME);
    String profileName = ConfigurationManager.getInstance().getContext(IConfigurationManager.PROFILENAME);
    // get app name
    inst.setValue("appname", nodeAppName);
    // get app des
    inst.setValue("appdes", "MSCP Application[" + appName + "] of NodeType[" + nodeAppName + "] with Profile[" + profileName + "]");
    // get the real path of application context root
    inst.setValue("webapproot", featureRootPath);
    // get the app Http URL
    inst.setValue("appurl", getServiceURI());
    // get app group
    getAppGroup(inst);
// get customized metrics
// getCustomizedMetrics(inst);
}
Also used : ProfileElementInstance(com.creditease.uav.profiling.spi.ProfileElementInstance)

Example 2 with ProfileElementInstance

use of com.creditease.uav.profiling.spi.ProfileElementInstance in project uavstack by uavorg.

the class StandardProfileElement method getInstance.

@Override
public ProfileElementInstance getInstance(String id) {
    if (null == id) {
        return null;
    }
    ProfileElementInstance inst = this.instances.get(id);
    if (null == inst) {
        synchronized (instances) {
            inst = this.instances.get(id);
            if (null == inst) {
                inst = new StandardProfileElementInstance(this, id, this.instances.size());
                this.instances.put(id, inst);
            }
        }
    }
    return inst;
}
Also used : ProfileElementInstance(com.creditease.uav.profiling.spi.ProfileElementInstance)

Example 3 with ProfileElementInstance

use of com.creditease.uav.profiling.spi.ProfileElementInstance in project uavstack by uavorg.

the class LogProfileHandler method profileFromJAppLogs.

/**
 * profileFromJAppLogs
 *
 * @param elem
 */
private void profileFromJAppLogs(ProfileElement elem) {
    String JAppLogs = System.getProperty("JAppLogs");
    if (JAppLogs == null) {
        return;
    }
    /**
     * JAppLogs: goes to log4j
     */
    ProfileElementInstance pei = elem.getInstance(LogProfileInfo.LogType.Log4j.toString());
    String[] logFilesStr = JAppLogs.split(";");
    for (String logFileStr : logFilesStr) {
        int index = logFileStr.indexOf("*");
        // normal file path
        if (index == -1) {
            pei.setValue(logFileStr, Collections.emptyMap());
        } else // file patterns under folder
        {
            String folder = logFileStr.substring(0, index);
            if (!IOHelper.exists(folder)) {
                continue;
            }
            List<File> files = IOHelper.getFiles(folder);
            for (File file : files) {
                pei.setValue(file.getAbsolutePath(), Collections.emptyMap());
            }
        }
    }
}
Also used : ProfileElementInstance(com.creditease.uav.profiling.spi.ProfileElementInstance) File(java.io.File)

Example 4 with ProfileElementInstance

use of com.creditease.uav.profiling.spi.ProfileElementInstance in project uavstack by uavorg.

the class LogProfileHandler method profileFromLogProfileInfo.

/**
 * profileFromLogProfileInfo
 *
 * @param elem
 * @param ic
 * @param appid
 */
private void profileFromLogProfileInfo(ProfileElement elem, InterceptContext ic, String appid) {
    @SuppressWarnings("unchecked") LinkedList<LogProfileInfo> list = (LinkedList<LogProfileInfo>) ic.get(HookConstants.LOG_PROFILE_LIST);
    if (list == null || list.size() == 0) {
        this.logger.warn("Profile:LOGS FAILs as LogProfileInfo List is null or its size 0", null);
        return;
    }
    // Log Source 1: AUTO Profiling
    for (LogProfileInfo logProfileInfo : list) {
        if (appid.equals(logProfileInfo.getAppId())) {
            ProfileElementInstance pei = elem.getInstance(logProfileInfo.getLogType().toString());
            String logPath = logProfileInfo.getFilePath();
            // set the log file path
            if (null != logPath) {
                pei.setValue(logPath, logProfileInfo.getAttributes());
            }
        }
    }
}
Also used : ProfileElementInstance(com.creditease.uav.profiling.spi.ProfileElementInstance) LogProfileInfo(com.creditease.uav.profiling.handlers.log.LogProfileInfo) LinkedList(java.util.LinkedList)

Example 5 with ProfileElementInstance

use of com.creditease.uav.profiling.spi.ProfileElementInstance in project uavstack by uavorg.

the class ProfileObserver method removeExpireIpLinkPEI.

@SuppressWarnings("unchecked")
private void removeExpireIpLinkPEI() {
    long curTime = System.currentTimeMillis();
    long appTimeout = DataConvertHelper.toLong(System.getProperty("com.creditease.uav.iplink.app.timeout"), 3600000);
    long userTimeout = DataConvertHelper.toLong(System.getProperty("com.creditease.uav.iplink.user.timeout"), 60000);
    long proxyTimeout = DataConvertHelper.toLong(System.getProperty("com.creditease.uav.iplink.proxy.timeout"), 3600000);
    long proxyAppTimeout = DataConvertHelper.toLong(System.getProperty("com.creditease.uav.iplink.proxy.app.timeout"), 3600000);
    long proxyUserTimeout = DataConvertHelper.toLong(System.getProperty("com.creditease.uav.iplink.proxy.user.timeout"), 60000);
    ProfileElement pe = this.profile.getRepository().getElement(ProfileConstants.PROELEM_IPLINK);
    ProfileElementInstance[] peis = pe.getInstances();
    for (ProfileElementInstance pei : peis) {
        // step 1: check pei expire
        String peiId = pei.getInstanceId();
        long peiTimeout = 0;
        if (peiId.indexOf("browser") == 0) {
            peiTimeout = userTimeout;
        } else if (peiId.indexOf("proxy") == 0) {
            peiTimeout = proxyTimeout;
        } else {
            peiTimeout = appTimeout;
        }
        long ts = (Long) pei.getValues().get("ts");
        if (curTime - ts > peiTimeout) {
            pe.removeInstance(pei.getInstanceId());
            continue;
        }
        // step 2: check pei's clients expire
        if (!pei.getValues().containsKey(ProfileConstants.PEI_CLIENTS)) {
            continue;
        }
        Map<String, Long> clients = (Map<String, Long>) pei.getValues().get(ProfileConstants.PEI_CLIENTS);
        for (String key : clients.keySet()) {
            Long clientts = (long) clients.get(key);
            long clientTimeout = 0;
            if (key.indexOf("user") == 0) {
                clientTimeout = proxyUserTimeout;
            } else {
                clientTimeout = proxyAppTimeout;
            }
            if (curTime - clientts > clientTimeout) {
                clients.remove(key);
            }
        }
    }
}
Also used : ProfileElementInstance(com.creditease.uav.profiling.spi.ProfileElementInstance) ProfileElement(com.creditease.uav.profiling.spi.ProfileElement) Map(java.util.Map)

Aggregations

ProfileElementInstance (com.creditease.uav.profiling.spi.ProfileElementInstance)14 InterceptContext (com.creditease.monitor.interceptframework.spi.InterceptContext)5 Map (java.util.Map)4 UAVServer (com.creditease.monitor.UAVServer)3 HashMap (java.util.HashMap)3 LinkedHashMap (java.util.LinkedHashMap)3 FastClasspathScanner (io.github.lukehutch.fastclasspathscanner.FastClasspathScanner)2 ServerVendor (com.creditease.monitor.UAVServer.ServerVendor)1 DubboServiceProfileInfo (com.creditease.uav.profiling.handlers.dubbo.DubboServiceProfileInfo)1 LogProfileInfo (com.creditease.uav.profiling.handlers.log.LogProfileInfo)1 ProfileElement (com.creditease.uav.profiling.spi.ProfileElement)1 LimitLinkedHashMap (com.creditease.uav.util.LimitLinkedHashMap)1 File (java.io.File)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 URL (java.net.URL)1 URLClassLoader (java.net.URLClassLoader)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1