Search in sources :

Example 1 with ResponseHistogramBuilder

use of com.navercorp.pinpoint.web.vo.ResponseHistogramBuilder 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)

Aggregations

SpanBo (com.navercorp.pinpoint.common.server.bo.SpanBo)1 ApplicationMap (com.navercorp.pinpoint.web.applicationmap.ApplicationMap)1 ApplicationMapBuilder (com.navercorp.pinpoint.web.applicationmap.ApplicationMapBuilder)1 LinkDataDuplexMap (com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataDuplexMap)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