Search in sources :

Example 1 with LinkDataMap

use of com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap 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 LinkDataMap

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

the class FilteredMapServiceImpl method addNodeFromSpanEvent.

private void addNodeFromSpanEvent(SpanBo span, TimeWindow window, LinkDataDuplexMap linkDataDuplexMap, Map<Long, SpanBo> transactionSpanMap) {
    /*
         * add span event statistics
         */
    final List<SpanEventBo> spanEventBoList = span.getSpanEventBoList();
    if (CollectionUtils.isEmpty(spanEventBoList)) {
        return;
    }
    final Application srcApplication = applicationFactory.createApplication(span.getApplicationId(), span.getApplicationServiceType());
    LinkDataMap sourceLinkDataMap = linkDataDuplexMap.getSourceLinkDataMap();
    for (SpanEventBo spanEvent : spanEventBoList) {
        ServiceType destServiceType = registry.findServiceType(spanEvent.getServiceType());
        if (!destServiceType.isRecordStatistics()) {
            // internal method
            continue;
        }
        // logic for checking acceptor
        if (destServiceType.isRpcClient()) {
            if (!transactionSpanMap.containsKey(spanEvent.getNextSpanId())) {
                destServiceType = ServiceType.UNKNOWN;
            }
        }
        String dest = spanEvent.getDestinationId();
        if (dest == null) {
            dest = "Unknown";
        }
        final Application destApplication = this.applicationFactory.createApplication(dest, destServiceType);
        final short slotTime = getHistogramSlotTime(spanEvent, destServiceType);
        // FIXME
        final long spanEventTimeStamp = window.refineTimestamp(span.getStartTime() + spanEvent.getStartElapsed());
        if (logger.isTraceEnabled()) {
            logger.trace("spanEvent  src:{} {} -> dest:{} {}", srcApplication, span.getAgentId(), destApplication, spanEvent.getEndPoint());
        }
        // endPoint may be null
        final String destinationAgentId = StringUtils.defaultString(spanEvent.getEndPoint());
        sourceLinkDataMap.addLinkData(srcApplication, span.getAgentId(), destApplication, destinationAgentId, spanEventTimeStamp, slotTime, 1);
    }
}
Also used : ServiceType(com.navercorp.pinpoint.common.trace.ServiceType) Application(com.navercorp.pinpoint.web.vo.Application) SpanEventBo(com.navercorp.pinpoint.common.server.bo.SpanEventBo) LinkDataMap(com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap)

Example 3 with LinkDataMap

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

the class ResponseTimeHistogramServiceImpl method selectNodeHistogramData.

@Override
public NodeHistogramSummary selectNodeHistogramData(ResponseTimeHistogramServiceOption option) {
    Node node = new Node(option.getApplication());
    ServiceType applicationServiceType = option.getApplication().getServiceType();
    List<Application> sourceApplications = option.getFromApplications();
    List<Application> destinationApplications = option.getToApplications();
    final NodeHistogramFactory nodeHistogramFactory = createNodeHistogramFactory();
    final ServerInstanceListFactory serverInstanceListFactory = createServerInstanceListFactory(option);
    if (applicationServiceType.isWas()) {
        NodeHistogram nodeHistogram = nodeHistogramFactory.createWasNodeHistogram(option.getApplication(), option.getRange());
        node.setNodeHistogram(nodeHistogram);
        ServerInstanceList serverInstanceList = serverInstanceListFactory.createWasNodeInstanceList(node, option.getRange().getTo());
        return new NodeHistogramSummary(serverInstanceList, nodeHistogram);
    } else if (applicationServiceType.isTerminal() || applicationServiceType.isUnknown() || applicationServiceType.isAlias()) {
        if (sourceApplications.isEmpty()) {
            return createEmptyNodeHistogramSummary(serverInstanceListFactory, option.getApplication(), option.getRange());
        }
        LinkDataMapProcessor destinationApplicationFilter = new DestinationApplicationFilter(option.getApplication());
        LinkSelector linkSelector = linkSelectorFactory.createLinkSelector(LinkSelectorType.UNIDIRECTIONAL, destinationApplicationFilter, LinkDataMapProcessor.NO_OP);
        LinkDataDuplexMap linkDataDuplexMap = linkSelector.select(sourceApplications, option.getRange(), 1, 0);
        ServerInstanceList serverInstanceList = serverInstanceListFactory.createEmptyNodeInstanceList();
        if (applicationServiceType.isTerminal() || applicationServiceType.isAlias()) {
            serverInstanceList = serverInstanceListFactory.createTerminalNodeInstanceList(node, linkDataDuplexMap);
        }
        NodeList nodeList = NodeListFactory.createNodeList(NodeType.DETAILED, linkDataDuplexMap);
        LinkList linkList = LinkListFactory.createLinkList(LinkType.DETAILED, nodeList, linkDataDuplexMap, option.getRange());
        NodeHistogram nodeHistogram = nodeHistogramFactory.createTerminalNodeHistogram(option.getApplication(), option.getRange(), linkList);
        return new NodeHistogramSummary(serverInstanceList, nodeHistogram);
    } else if (applicationServiceType.isQueue()) {
        LinkDataMapProcessor destinationApplicationFilter = new DestinationApplicationFilter(option.getApplication());
        if (sourceApplications.isEmpty()) {
            if (destinationApplications.isEmpty()) {
                return createEmptyNodeHistogramSummary(serverInstanceListFactory, option.getApplication(), option.getRange());
            }
            // Retrieve callers
            LinkDataMapProcessor applicationFilter = new ApplicationFilter(option.getApplication());
            LinkSelector linkSelector = linkSelectorFactory.createLinkSelector(LinkSelectorType.UNIDIRECTIONAL, LinkDataMapProcessor.NO_OP, applicationFilter);
            LinkDataDuplexMap linkDataDuplexMap = linkSelector.select(sourceApplications, option.getRange(), 0, 2);
            LinkDataMap linkDataMap = destinationApplicationFilter.processLinkDataMap(linkDataDuplexMap.getTargetLinkDataMap(), option.getRange());
            for (LinkData linkData : linkDataMap.getLinkDataList()) {
                sourceApplications.add(linkData.getFromApplication());
            }
        }
        // Check using from applications first for caller's link data
        LinkSelector linkSelector = linkSelectorFactory.createLinkSelector(LinkSelectorType.UNIDIRECTIONAL, destinationApplicationFilter, LinkDataMapProcessor.NO_OP);
        LinkDataDuplexMap linkDataDuplexMap = linkSelector.select(sourceApplications, option.getRange(), 1, 0);
        ServerInstanceList serverInstanceList = serverInstanceListFactory.createQueueNodeInstanceList(node, linkDataDuplexMap);
        NodeList nodeList = NodeListFactory.createNodeList(NodeType.DETAILED, linkDataDuplexMap);
        LinkList linkList = LinkListFactory.createLinkList(LinkType.DETAILED, nodeList, linkDataDuplexMap, option.getRange());
        NodeHistogram nodeHistogram = nodeHistogramFactory.createQueueNodeHistogram(option.getApplication(), option.getRange(), linkList);
        return new NodeHistogramSummary(serverInstanceList, nodeHistogram);
    } else if (applicationServiceType.isUser()) {
        if (destinationApplications.isEmpty()) {
            return createEmptyNodeHistogramSummary(serverInstanceListFactory, option.getApplication(), option.getRange());
        }
        LinkDataMapProcessor sourceApplicationFilter = new SourceApplicationFilter(option.getApplication());
        LinkSelector linkSelector = linkSelectorFactory.createLinkSelector(LinkSelectorType.UNIDIRECTIONAL, LinkDataMapProcessor.NO_OP, sourceApplicationFilter);
        LinkDataDuplexMap linkDataDuplexMap = linkSelector.select(destinationApplications, option.getRange(), 0, 1);
        ServerInstanceList serverInstanceList = serverInstanceListFactory.createUserNodeInstanceList();
        NodeList nodeList = NodeListFactory.createNodeList(NodeType.DETAILED, linkDataDuplexMap);
        LinkList linkList = LinkListFactory.createLinkList(LinkType.DETAILED, nodeList, linkDataDuplexMap, option.getRange());
        NodeHistogram nodeHistogram = nodeHistogramFactory.createUserNodeHistogram(option.getApplication(), option.getRange(), linkList);
        return new NodeHistogramSummary(serverInstanceList, nodeHistogram);
    } else {
        return createEmptyNodeHistogramSummary(serverInstanceListFactory, option.getApplication(), option.getRange());
    }
}
Also used : SourceApplicationFilter(com.navercorp.pinpoint.web.service.map.processor.SourceApplicationFilter) ServerInstanceListFactory(com.navercorp.pinpoint.web.applicationmap.appender.server.ServerInstanceListFactory) DefaultServerInstanceListFactory(com.navercorp.pinpoint.web.applicationmap.appender.server.DefaultServerInstanceListFactory) StatisticsServerInstanceListFactory(com.navercorp.pinpoint.web.applicationmap.appender.server.StatisticsServerInstanceListFactory) LinkData(com.navercorp.pinpoint.web.applicationmap.rawdata.LinkData) NodeHistogramSummary(com.navercorp.pinpoint.web.applicationmap.nodes.NodeHistogramSummary) Node(com.navercorp.pinpoint.web.applicationmap.nodes.Node) ServerInstanceList(com.navercorp.pinpoint.web.applicationmap.nodes.ServerInstanceList) NodeList(com.navercorp.pinpoint.web.applicationmap.nodes.NodeList) NodeHistogram(com.navercorp.pinpoint.web.applicationmap.histogram.NodeHistogram) LinkSelector(com.navercorp.pinpoint.web.service.map.LinkSelector) LinkDataDuplexMap(com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataDuplexMap) DestinationApplicationFilter(com.navercorp.pinpoint.web.service.map.processor.DestinationApplicationFilter) DefaultNodeHistogramFactory(com.navercorp.pinpoint.web.applicationmap.appender.histogram.DefaultNodeHistogramFactory) NodeHistogramFactory(com.navercorp.pinpoint.web.applicationmap.appender.histogram.NodeHistogramFactory) ServiceType(com.navercorp.pinpoint.common.trace.ServiceType) LinkDataMapProcessor(com.navercorp.pinpoint.web.service.map.processor.LinkDataMapProcessor) DestinationApplicationFilter(com.navercorp.pinpoint.web.service.map.processor.DestinationApplicationFilter) SourceApplicationFilter(com.navercorp.pinpoint.web.service.map.processor.SourceApplicationFilter) ApplicationFilter(com.navercorp.pinpoint.web.service.map.processor.ApplicationFilter) LinkList(com.navercorp.pinpoint.web.applicationmap.link.LinkList) Application(com.navercorp.pinpoint.web.vo.Application) LinkDataMap(com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap)

Example 4 with LinkDataMap

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

the class VirtualLinkHandler method getEmulatedNodeCalleeLinkData.

private Collection<LinkData> getEmulatedNodeCalleeLinkData(LinkVisitChecker linkVisitChecker, Application emulatedNode, Range range) {
    LinkDataMap calleeLinkDataMap = linkDataMapService.selectCalleeLinkDataMap(emulatedNode, range);
    logger.debug("emulated node [{}] callee LinkDataMap:{}", emulatedNode, calleeLinkDataMap);
    LinkDataMap filteredCalleeLinkDataMap = new LinkDataMap();
    for (LinkData calleeLinkData : calleeLinkDataMap.getLinkDataList()) {
        Application fromApplication = calleeLinkData.getFromApplication();
        // filter callee link data from non-WAS nodes
        if (!fromApplication.getServiceType().isWas()) {
            logger.trace("filtered {} as {} is not a WAS node", calleeLinkData, fromApplication);
            continue;
        }
        // filter callee link data from nodes that haven't been visited as we don't need them
        if (!linkVisitChecker.isVisitedCaller(fromApplication)) {
            logger.trace("filtered {} as {} is not in scope of the current server map", calleeLinkData, fromApplication);
            continue;
        }
        logger.debug("emulated node [{}] callee LinkData:{}", emulatedNode, calleeLinkData);
        filteredCalleeLinkDataMap.addLinkData(calleeLinkData);
    }
    logger.debug("emulated node [{}] filtered callee LinkDataMap:{}", emulatedNode, filteredCalleeLinkDataMap);
    return filteredCalleeLinkDataMap.getLinkDataList();
}
Also used : LinkData(com.navercorp.pinpoint.web.applicationmap.rawdata.LinkData) Application(com.navercorp.pinpoint.web.vo.Application) LinkDataMap(com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap)

Example 5 with LinkDataMap

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

the class FilteredMapBuilder method addNodeFromSpanEvent.

private void addNodeFromSpanEvent(SpanBo span, Application srcApplication, MultiValueMap<Long, SpanBo> transactionSpanMap) {
    /*
         * add span event statistics
         */
    LinkDataMap sourceLinkDataMap = linkDataDuplexMap.getSourceLinkDataMap();
    SpanAcceptor acceptor = new SpanReader(Collections.singletonList(span));
    acceptor.accept(new SpanEventVisitAdaptor(new SpanEventVisitor() {

        @Override
        public boolean visit(SpanEventBo spanEventBo) {
            addNode(span, transactionSpanMap, srcApplication, sourceLinkDataMap, spanEventBo);
            return SpanVisitor.REJECT;
        }
    }));
}
Also used : SpanReader(com.navercorp.pinpoint.web.filter.visitor.SpanReader) SpanEventVisitAdaptor(com.navercorp.pinpoint.web.filter.visitor.SpanEventVisitAdaptor) SpanAcceptor(com.navercorp.pinpoint.web.filter.visitor.SpanAcceptor) SpanEventVisitor(com.navercorp.pinpoint.web.filter.visitor.SpanEventVisitor) SpanEventBo(com.navercorp.pinpoint.common.server.bo.SpanEventBo) LinkDataMap(com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap)

Aggregations

LinkDataMap (com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap)35 Application (com.navercorp.pinpoint.web.vo.Application)30 Test (org.junit.Test)22 LinkData (com.navercorp.pinpoint.web.applicationmap.rawdata.LinkData)20 LinkDataDuplexMap (com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataDuplexMap)15 LinkKey (com.navercorp.pinpoint.web.vo.LinkKey)14 Range (com.navercorp.pinpoint.web.vo.Range)14 ServiceType (com.navercorp.pinpoint.common.trace.ServiceType)9 AcceptApplication (com.navercorp.pinpoint.web.service.map.AcceptApplication)6 VirtualLinkMarker (com.navercorp.pinpoint.web.service.map.VirtualLinkMarker)6 LinkCallData (com.navercorp.pinpoint.web.applicationmap.rawdata.LinkCallData)4 WasOnlyProcessor (com.navercorp.pinpoint.web.service.map.processor.WasOnlyProcessor)4 SpanBo (com.navercorp.pinpoint.common.server.bo.SpanBo)3 SpanEventBo (com.navercorp.pinpoint.common.server.bo.SpanEventBo)3 TimeWindow (com.navercorp.pinpoint.web.util.TimeWindow)3 Buffer (com.navercorp.pinpoint.common.buffer.Buffer)2 FixedBuffer (com.navercorp.pinpoint.common.buffer.FixedBuffer)2 LinkCallDataMap (com.navercorp.pinpoint.web.applicationmap.rawdata.LinkCallDataMap)2 MapStatisticsTimeWindowReducer (com.navercorp.pinpoint.web.mapper.MapStatisticsTimeWindowReducer)2 RowMapReduceResultExtractor (com.navercorp.pinpoint.web.mapper.RowMapReduceResultExtractor)2