Search in sources :

Example 1 with ProfileContext

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

the class AppProfilingListener method handleEvent.

@Override
public void handleEvent(InterceptContext context) {
    // get the context path
    String contextpath = (String) context.get(InterceptConstants.CONTEXTPATH);
    String basepath = (String) context.get(InterceptConstants.BASEPATH);
    // swtich event
    Event event = context.getEvent();
    // create the profile context object
    ProfileContext profilecontext = new StandardProfileContext();
    // put InterceptContext into profile context, then profile handler can get info from InterceptContext
    profilecontext.put(InterceptContext.class, context);
    // get the profile factory
    ProfileFactory pf = ProfileFactory.instance();
    switch(event) {
        case AFTER_SERVET_INIT:
            break;
        case BEFORE_SERVLET_DESTROY:
            break;
        case WEBCONTAINER_STARTED:
            startProfiling(contextpath, basepath, pf, profilecontext);
            break;
        case WEBCONTAINER_STOPPED:
            stopProfiling(contextpath, basepath, pf);
            break;
        default:
            break;
    }
}
Also used : StandardProfileContext(com.creditease.uav.profiling.StandardProfileContext) ProfileContext(com.creditease.uav.profiling.spi.ProfileContext) ProfileFactory(com.creditease.uav.profiling.spi.ProfileFactory) Event(com.creditease.monitor.interceptframework.spi.InterceptContext.Event) StandardProfileContext(com.creditease.uav.profiling.StandardProfileContext)

Example 2 with ProfileContext

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

the class ServerEndRespTimeCapHandler method doProfileIPLink.

/**
 * NOTE: as client ip links are generated by runtime invoking, we have to do this in monitor
 *
 * @param context
 * @param appName
 * @param url
 */
private void doProfileIPLink(CaptureContext context, String appId, String url) {
    String clientAddr = (String) context.get(CaptureConstants.INFO_APPSERVER_CONNECTOR_CLIENTADDR);
    if (StringHelper.isEmpty(clientAddr)) {
        return;
    }
    Profile p = ProfileFactory.instance().getProfile(appId);
    if (p == null) {
        return;
    }
    ProfileContext pc = new StandardProfileContext();
    pc.put(ProfileConstants.PC_ARG_CLIENTADDR, clientAddr);
    String uavClientTag = (String) context.get(CaptureConstants.INFO_APPSERVER_UAVCLIENT_TAG);
    if (!StringHelper.isEmpty(uavClientTag)) {
        pc.put(ProfileConstants.PC_ARG_UAVCLIENT_TAG, uavClientTag);
    }
    String forwardIPLink = (String) context.get(CaptureConstants.INFO_APPSERVER_CONNECTOR_FORWARDADDR);
    if (!StringHelper.isEmpty(forwardIPLink)) {
        pc.put(ProfileConstants.PC_ARG_IPLNK, forwardIPLink);
    }
    if (!StringHelper.isEmpty(url)) {
        pc.put(ProfileConstants.PC_ARG_IPLINK_TARGETURL, url);
    }
    String userAgent = (String) context.get(CaptureConstants.INFO_APPSERVER_CLIENT_USRAGENT);
    if (!StringHelper.isEmpty(userAgent)) {
        pc.put(ProfileConstants.PC_ARG_IPLINK_USRAGENT, userAgent);
    }
    String proxyhost = (String) context.get(CaptureConstants.INFO_APPSERVER_PROXY_HOST);
    if (!StringHelper.isEmpty(proxyhost)) {
        pc.put(ProfileConstants.PC_ARG_PROXYHOST, proxyhost);
    }
    pc.put(ProfileConstants.PC_ARG_APPID, appId);
    pc.put(ProfileConstants.PC_ARG_SVRHOST, this.serverAddress);
    pc.addPE(ProfileConstants.PROELEM_IPLINK);
    p.doProfiling(pc);
}
Also used : StandardProfileContext(com.creditease.uav.profiling.StandardProfileContext) ProfileContext(com.creditease.uav.profiling.spi.ProfileContext) StandardProfileContext(com.creditease.uav.profiling.StandardProfileContext) Profile(com.creditease.uav.profiling.spi.Profile)

Example 3 with ProfileContext

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

the class ClientRespTimeCapHandler method doProfileClient.

/**
 * do client profiling
 *
 * @param context
 * @param clientRequestURL
 */
private void doProfileClient(CaptureContext context, String clientRequestURL, String appid) {
    Profile p = ProfileFactory.instance().getProfile(appid);
    if (p != null) {
        ProfileContext pc = new StandardProfileContext();
        String action = (String) context.get(CaptureConstants.INFO_CLIENT_REQUEST_ACTION);
        Integer rc = (Integer) context.get(CaptureConstants.INFO_CLIENT_RESPONSECODE);
        String type = (String) context.get(CaptureConstants.INFO_CLIENT_TYPE);
        String server = (String) context.get(CaptureConstants.INFO_CLIENT_TARGETSERVER);
        pc.put(ProfileConstants.PC_ARG_CLIENT_URL, clientRequestURL);
        pc.put(ProfileConstants.PC_ARG_CLIENT_ACTION, action);
        pc.put(ProfileConstants.PC_ARG_CLIENT_RC, rc);
        pc.put(ProfileConstants.PC_ARG_CLIENT_TYPE, type);
        pc.put(ProfileConstants.PC_ARG_CLIENT_TARGETSERVER, server);
        pc.addPE(ProfileConstants.PROELEM_CLIENT);
        p.doProfiling(pc);
    }
}
Also used : StandardProfileContext(com.creditease.uav.profiling.StandardProfileContext) ProfileContext(com.creditease.uav.profiling.spi.ProfileContext) StandardProfileContext(com.creditease.uav.profiling.StandardProfileContext) Profile(com.creditease.uav.profiling.spi.Profile)

Aggregations

StandardProfileContext (com.creditease.uav.profiling.StandardProfileContext)3 ProfileContext (com.creditease.uav.profiling.spi.ProfileContext)3 Profile (com.creditease.uav.profiling.spi.Profile)2 Event (com.creditease.monitor.interceptframework.spi.InterceptContext.Event)1 ProfileFactory (com.creditease.uav.profiling.spi.ProfileFactory)1