Search in sources :

Example 1 with ApplicationMapBuilder

use of com.navercorp.pinpoint.web.applicationmap.ApplicationMapBuilder in project pinpoint by naver.

the class FilteredMapServiceImpl method createMap.

private ApplicationMap createMap(Range range, Range scanRange, List<List<SpanBo>> filterList) {
    // TODO inject TimeWindow from elsewhere 
    final TimeWindow window = new TimeWindow(range, TimeWindowDownSampler.SAMPLER);
    final LinkDataDuplexMap linkDataDuplexMap = new LinkDataDuplexMap();
    final ResponseHistogramBuilder mapHistogramSummary = new ResponseHistogramBuilder(range);
    /*
         * Convert to statistical data
         */
    for (List<SpanBo> transaction : filterList) {
        final Map<Long, SpanBo> transactionSpanMap = checkDuplicatedSpanId(transaction);
        for (SpanBo span : transaction) {
            final Application parentApplication = createParentApplication(span, transactionSpanMap);
            final Application spanApplication = this.applicationFactory.createApplication(span.getApplicationId(), span.getApplicationServiceType());
            // records the Span's response time statistics
            recordSpanResponseTime(spanApplication, span, mapHistogramSummary, span.getCollectorAcceptTime());
            if (!spanApplication.getServiceType().isRecordStatistics() || spanApplication.getServiceType().isRpcClient()) {
                // span's serviceType is probably not set correctly
                logger.warn("invalid span application:{}", spanApplication);
                continue;
            }
            final short slotTime = getHistogramSlotTime(span, spanApplication.getServiceType());
            // might need to reconsider using collector's accept time for link statistics.
            // we need to convert to time window's timestamp. If not, it may lead to OOM due to mismatch in timeslots. 
            long timestamp = window.refineTimestamp(span.getCollectorAcceptTime());
            if (parentApplication.getServiceType() == ServiceType.USER) {
                // Outbound data
                if (logger.isTraceEnabled()) {
                    logger.trace("span user:{} {} -> span:{} {}", parentApplication, span.getAgentId(), spanApplication, span.getAgentId());
                }
                final LinkDataMap sourceLinkData = linkDataDuplexMap.getSourceLinkDataMap();
                sourceLinkData.addLinkData(parentApplication, span.getAgentId(), spanApplication, span.getAgentId(), timestamp, slotTime, 1);
                if (logger.isTraceEnabled()) {
                    logger.trace("span target user:{} {} -> span:{} {}", parentApplication, span.getAgentId(), spanApplication, span.getAgentId());
                }
                // Inbound data
                final LinkDataMap targetLinkDataMap = linkDataDuplexMap.getTargetLinkDataMap();
                targetLinkDataMap.addLinkData(parentApplication, span.getAgentId(), spanApplication, span.getAgentId(), timestamp, slotTime, 1);
            } else {
                // Inbound data
                if (logger.isTraceEnabled()) {
                    logger.trace("span target parent:{} {} -> span:{} {}", parentApplication, span.getAgentId(), spanApplication, span.getAgentId());
                }
                final LinkDataMap targetLinkDataMap = linkDataDuplexMap.getTargetLinkDataMap();
                targetLinkDataMap.addLinkData(parentApplication, span.getAgentId(), spanApplication, span.getAgentId(), timestamp, slotTime, 1);
            }
            if (serverMapDataFilter != null && serverMapDataFilter.filter(spanApplication)) {
                continue;
            }
            addNodeFromSpanEvent(span, window, linkDataDuplexMap, transactionSpanMap);
        }
    }
    ApplicationMapBuilder applicationMapBuilder = new ApplicationMapBuilder(range);
    mapHistogramSummary.build();
    ApplicationMap map = applicationMapBuilder.build(linkDataDuplexMap, agentInfoService, mapHistogramSummary);
    if (serverMapDataFilter != null) {
        map = serverMapDataFilter.dataFiltering(map);
    }
    return map;
}
Also used : ApplicationMap(com.navercorp.pinpoint.web.applicationmap.ApplicationMap) LinkDataDuplexMap(com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataDuplexMap) TimeWindow(com.navercorp.pinpoint.web.util.TimeWindow) SpanBo(com.navercorp.pinpoint.common.server.bo.SpanBo) ApplicationMapBuilder(com.navercorp.pinpoint.web.applicationmap.ApplicationMapBuilder) ResponseHistogramBuilder(com.navercorp.pinpoint.web.vo.ResponseHistogramBuilder) Application(com.navercorp.pinpoint.web.vo.Application) LinkDataMap(com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap)

Example 2 with ApplicationMapBuilder

use of com.navercorp.pinpoint.web.applicationmap.ApplicationMapBuilder in project pinpoint by naver.

the class MapServiceImpl method selectApplicationMap.

/**
     * Used in the main UI - draws the server map by querying the timeslot by time.
     */
@Override
public ApplicationMap selectApplicationMap(Application sourceApplication, Range range, SearchOption searchOption) {
    if (sourceApplication == null) {
        throw new NullPointerException("sourceApplication must not be null");
    }
    if (range == null) {
        throw new NullPointerException("range must not be null");
    }
    logger.debug("SelectApplicationMap");
    StopWatch watch = new StopWatch("ApplicationMap");
    watch.start("ApplicationMap Hbase Io Fetch(Caller,Callee) Time");
    LinkSelector linkSelector = new BFSLinkSelector(this.mapStatisticsCallerDao, this.mapStatisticsCalleeDao, hostApplicationMapDao, serverMapDataFilter);
    LinkDataDuplexMap linkDataDuplexMap = linkSelector.select(sourceApplication, range, searchOption);
    watch.stop();
    watch.start("ApplicationMap MapBuilding(Response) Time");
    ApplicationMapBuilder builder = new ApplicationMapBuilder(range);
    ApplicationMap map = builder.build(linkDataDuplexMap, agentInfoService, this.mapResponseDao);
    if (map.getNodes().isEmpty()) {
        map = builder.build(sourceApplication, agentInfoService);
    }
    watch.stop();
    if (logger.isInfoEnabled()) {
        logger.info("ApplicationMap BuildTime: {}", watch.prettyPrint());
    }
    if (serverMapDataFilter != null) {
        map = serverMapDataFilter.dataFiltering(map);
    }
    return map;
}
Also used : ApplicationMap(com.navercorp.pinpoint.web.applicationmap.ApplicationMap) LinkDataDuplexMap(com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataDuplexMap) StopWatch(org.springframework.util.StopWatch) ApplicationMapBuilder(com.navercorp.pinpoint.web.applicationmap.ApplicationMapBuilder)

Aggregations

ApplicationMap (com.navercorp.pinpoint.web.applicationmap.ApplicationMap)2 ApplicationMapBuilder (com.navercorp.pinpoint.web.applicationmap.ApplicationMapBuilder)2 LinkDataDuplexMap (com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataDuplexMap)2 SpanBo (com.navercorp.pinpoint.common.server.bo.SpanBo)1 LinkDataMap (com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap)1 TimeWindow (com.navercorp.pinpoint.web.util.TimeWindow)1 Application (com.navercorp.pinpoint.web.vo.Application)1 ResponseHistogramBuilder (com.navercorp.pinpoint.web.vo.ResponseHistogramBuilder)1 StopWatch (org.springframework.util.StopWatch)1