Search in sources :

Example 1 with ServiceMapBinding

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

the class doTestProfileServiceMapMgr method test.

private static long test(ProfileServiceMapMgr psmm, String test1) {
    long st = System.currentTimeMillis();
    ServiceMapBinding smb = psmm.searchServiceMapBinding("test", test1);
    long cost = System.currentTimeMillis() - st;
    System.out.println(smb.toString() + ":" + cost);
    return cost;
}
Also used : ServiceMapBinding(com.creditease.uav.profiling.spi.ProfileServiceMapMgr.ServiceMapBinding)

Example 2 with ServiceMapBinding

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

the class ServiceSpanInvokeChainHandler method doCap.

/**
 * Finish Span and Logger the Span metrics
 */
@Override
public void doCap(InvokeChainContext context) {
    /**
     * Step 1: try to get service span,
     */
    // 移除main,防止uav没有劫持到的请求发生调用链连接现象
    this.spanFactory.getRemoveSpanFromContext("main");
    String url = (String) context.get(CaptureConstants.INFO_APPSERVER_CONNECTOR_REQUEST_URL);
    Span span;
    if (UAVServer.instance().isExistSupportor("com.creditease.uav.apm.supporters.SlowOperSupporter")) {
        span = this.spanFactory.getSpanFromContext(url);
    } else {
        span = this.spanFactory.getRemoveSpanFromContext(url);
    }
    if (span == null) {
        return;
    }
    String appid = null;
    if (context.get(CaptureConstants.INFO_CLIENT_APPID) != null && !StringHelper.isEmpty(context.get(CaptureConstants.INFO_CLIENT_APPID).toString())) {
        appid = (String) context.get(CaptureConstants.INFO_CLIENT_APPID);
        span.setClassName(context.get(InvokeChainConstants.CLIENT_IT_CLASS).toString());
        span.setMethodName(context.get(InvokeChainConstants.CLIENT_IT_METHOD).toString());
        String responseState = (String) context.get(CaptureConstants.INFO_CLIENT_RESPONSESTATE);
        span.setState(context.get(CaptureConstants.INFO_CLIENT_RESPONSECODE).toString(), responseState);
    } else if (context.get(CaptureConstants.INFO_APPSERVER_APPID) != null && !StringHelper.isEmpty(context.get(CaptureConstants.INFO_APPSERVER_APPID).toString())) {
        appid = (String) context.get(CaptureConstants.INFO_APPSERVER_APPID);
        span.setClassName(context.get(InvokeChainConstants.CLIENT_IT_CLASS).toString());
        span.setMethodName(context.get(InvokeChainConstants.CLIENT_IT_METHOD).toString());
        String responseState = (String) context.get(CaptureConstants.INFO_CLIENT_RESPONSESTATE);
        span.setState(context.get(CaptureConstants.INFO_APPSERVER_CONNECTOR_RESPONSECODE).toString(), responseState);
    } else {
        String appContext = (String) context.get(CaptureConstants.INFO_APPSERVER_CONNECTOR_CONTEXT);
        String realpath = (String) context.get(CaptureConstants.INFO_APPSERVER_CONNECTOR_CONTEXT_REALPATH);
        if (null == appContext && null == realpath) {
            return;
        }
        appid = MonitorServerUtil.getApplicationId(appContext, realpath);
        if (appid == null) {
            return;
        }
        /**
         * match service class & method
         */
        ProfileServiceMapMgr smgr = (ProfileServiceMapMgr) UAVServer.instance().getServerInfo("profile.servicemapmgr");
        ServiceMapBinding smb = smgr.searchServiceMapBinding(appid, url);
        if (smb != null) {
            span.setClassName(smb.getClazz());
            if (StringHelper.isEmpty(span.getMethodName())) {
                span.setMethodName(smb.getMethod());
            }
        }
        span.setState(context.get(CaptureConstants.INFO_APPSERVER_CONNECTOR_RESPONSECODE).toString(), null);
    }
    context.put(CaptureConstants.INFO_APPSERVER_APPID, appid);
    /**
     * Step 2: end span
     */
    span.end();
    /**
     * Step 3: set service span info
     */
    span.setAppid(appid);
    span.setUrl(url);
    String spanLog = span.toString();
    if (logger.isDebugable()) {
        logger.debug("doCap:span=" + spanLog, null);
    }
    /**
     * Step 3: get the related invokechain logger of this application to record span
     */
    DataLogger invokeChainLogger = this.getAppInvokeChainLogger(appid);
    if (invokeChainLogger == null) {
        return;
    }
    invokeChainLogger.logData(spanLog);
}
Also used : ServiceMapBinding(com.creditease.uav.profiling.spi.ProfileServiceMapMgr.ServiceMapBinding) DataLogger(com.creditease.monitor.log.DataLogger) Span(com.creditease.uav.apm.invokechain.span.Span) ProfileServiceMapMgr(com.creditease.uav.profiling.spi.ProfileServiceMapMgr)

Aggregations

ServiceMapBinding (com.creditease.uav.profiling.spi.ProfileServiceMapMgr.ServiceMapBinding)2 DataLogger (com.creditease.monitor.log.DataLogger)1 Span (com.creditease.uav.apm.invokechain.span.Span)1 ProfileServiceMapMgr (com.creditease.uav.profiling.spi.ProfileServiceMapMgr)1