Search in sources :

Example 1 with ApplicationTimeHistogram

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

the class ApplicationMapBuilder method appendNodeResponseTime.

public void appendNodeResponseTime(NodeList nodeList, LinkList linkList, NodeHistogramDataSource nodeHistogramDataSource) {
    if (nodeHistogramDataSource == null) {
        throw new NullPointerException("nodeHistogramDataSource must not be null");
    }
    final Collection<Node> nodes = nodeList.getNodeList();
    for (Node node : nodes) {
        final ServiceType nodeType = node.getServiceType();
        if (nodeType.isWas()) {
            // for WAS nodes, set their own response time histogram
            final Application wasNode = node.getApplication();
            final NodeHistogram nodeHistogram = nodeHistogramDataSource.createNodeHistogram(wasNode);
            node.setNodeHistogram(nodeHistogram);
        } else if (nodeType.isTerminal() || nodeType.isUnknown()) {
            final NodeHistogram nodeHistogram = createTerminalNodeHistogram(node, linkList);
            node.setNodeHistogram(nodeHistogram);
        } else if (nodeType.isQueue()) {
            // Virtual queue node - queues with agent installed will be handled above as a WAS node
            final NodeHistogram nodeHistogram = createTerminalNodeHistogram(node, linkList);
            node.setNodeHistogram(nodeHistogram);
        } else if (nodeType.isUser()) {
            // for User nodes, find its source link and create the histogram
            Application userNode = node.getApplication();
            final NodeHistogram nodeHistogram = new NodeHistogram(userNode, range);
            final List<Link> fromLink = linkList.findFromLink(userNode);
            if (fromLink.size() > 1) {
                // used first(0) link.
                logger.warn("Invalid from UserNode:{}", linkList.getLinkList());
            } else if (fromLink.isEmpty()) {
                logger.warn("from UserNode not found:{}", userNode);
                continue;
            }
            final Link sourceLink = fromLink.get(0);
            nodeHistogram.setApplicationHistogram(sourceLink.getHistogram());
            ApplicationTimeHistogram histogramData = sourceLink.getTargetApplicationTimeSeriesHistogramData();
            nodeHistogram.setApplicationTimeHistogram(histogramData);
            node.setNodeHistogram(nodeHistogram);
        } else {
            // dummy data
            NodeHistogram dummy = new NodeHistogram(node.getApplication(), range);
            node.setNodeHistogram(dummy);
        }
    }
}
Also used : ApplicationTimeHistogram(com.navercorp.pinpoint.web.applicationmap.histogram.ApplicationTimeHistogram) ServiceType(com.navercorp.pinpoint.common.trace.ServiceType) NodeHistogram(com.navercorp.pinpoint.web.applicationmap.histogram.NodeHistogram) List(java.util.List) AgentHistogramList(com.navercorp.pinpoint.web.applicationmap.rawdata.AgentHistogramList) Application(com.navercorp.pinpoint.web.vo.Application)

Example 2 with ApplicationTimeHistogram

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

the class ApplicationTimeHistogramTest method testViewModel.

@Test
public void testViewModel() throws IOException {
    Application app = new Application("test", ServiceType.STAND_ALONE);
    ApplicationTimeHistogramBuilder builder = new ApplicationTimeHistogramBuilder(app, new Range(0, 10 * 6000));
    List<ResponseTime> responseHistogramList = createResponseTime(app);
    ApplicationTimeHistogram histogram = builder.build(responseHistogramList);
    List<ResponseTimeViewModel> viewModel = histogram.createViewModel();
    logger.debug("{}", viewModel);
    ObjectWriter writer = mapper.writer();
    String s = writer.writeValueAsString(viewModel);
    logger.debug(s);
}
Also used : ApplicationTimeHistogram(com.navercorp.pinpoint.web.applicationmap.histogram.ApplicationTimeHistogram) ApplicationTimeHistogramBuilder(com.navercorp.pinpoint.web.applicationmap.histogram.ApplicationTimeHistogramBuilder) ResponseTimeViewModel(com.navercorp.pinpoint.web.view.ResponseTimeViewModel) ObjectWriter(com.fasterxml.jackson.databind.ObjectWriter) ResponseTime(com.navercorp.pinpoint.web.vo.ResponseTime) Range(com.navercorp.pinpoint.web.vo.Range) Application(com.navercorp.pinpoint.web.vo.Application) Test(org.junit.Test)

Example 3 with ApplicationTimeHistogram

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

the class ApplicationMapBuilder method createTerminalNodeHistogram.

private NodeHistogram createTerminalNodeHistogram(Node node, LinkList linkList) {
    // for Terminal nodes, add all links pointing to iself and create the histogram
    final Application nodeApplication = node.getApplication();
    final NodeHistogram nodeHistogram = new NodeHistogram(nodeApplication, range);
    // create applicationHistogram
    final List<Link> toLinkList = linkList.findToLink(nodeApplication);
    final Histogram applicationHistogram = new Histogram(node.getServiceType());
    for (Link link : toLinkList) {
        applicationHistogram.add(link.getHistogram());
    }
    nodeHistogram.setApplicationHistogram(applicationHistogram);
    // create applicationTimeHistogram
    LinkCallDataMap linkCallDataMap = new LinkCallDataMap();
    for (Link link : toLinkList) {
        LinkCallDataMap sourceLinkCallDataMap = link.getSourceLinkCallDataMap();
        linkCallDataMap.addLinkDataMap(sourceLinkCallDataMap);
    }
    ApplicationTimeHistogramBuilder builder = new ApplicationTimeHistogramBuilder(nodeApplication, range);
    ApplicationTimeHistogram applicationTimeHistogram = builder.build(linkCallDataMap.getLinkDataList());
    nodeHistogram.setApplicationTimeHistogram(applicationTimeHistogram);
    // for Terminal nodes, create AgentLevel histogram
    if (nodeApplication.getServiceType().isTerminal() || nodeApplication.getServiceType().isQueue()) {
        final Map<String, Histogram> agentHistogramMap = new HashMap<>();
        for (Link link : toLinkList) {
            LinkCallDataMap sourceLinkCallDataMap = link.getSourceLinkCallDataMap();
            AgentHistogramList targetList = sourceLinkCallDataMap.getTargetList();
            for (AgentHistogram histogram : targetList.getAgentHistogramList()) {
                Histogram find = agentHistogramMap.get(histogram.getId());
                if (find == null) {
                    find = new Histogram(histogram.getServiceType());
                    agentHistogramMap.put(histogram.getId(), find);
                }
                find.add(histogram.getHistogram());
            }
            nodeHistogram.setAgentHistogramMap(agentHistogramMap);
        }
    }
    LinkCallDataMap mergeSource = new LinkCallDataMap();
    for (Link link : toLinkList) {
        LinkCallDataMap sourceLinkCallDataMap = link.getSourceLinkCallDataMap();
        mergeSource.addLinkDataMap(sourceLinkCallDataMap);
    }
    AgentTimeHistogramBuilder agentTimeBuilder = new AgentTimeHistogramBuilder(nodeApplication, range);
    AgentTimeHistogram agentTimeHistogram = agentTimeBuilder.buildTarget(mergeSource);
    nodeHistogram.setAgentTimeHistogram(agentTimeHistogram);
    return nodeHistogram;
}
Also used : AgentTimeHistogramBuilder(com.navercorp.pinpoint.web.applicationmap.histogram.AgentTimeHistogramBuilder) AgentTimeHistogram(com.navercorp.pinpoint.web.applicationmap.histogram.AgentTimeHistogram) AgentHistogram(com.navercorp.pinpoint.web.applicationmap.rawdata.AgentHistogram) Histogram(com.navercorp.pinpoint.web.applicationmap.histogram.Histogram) ApplicationTimeHistogram(com.navercorp.pinpoint.web.applicationmap.histogram.ApplicationTimeHistogram) NodeHistogram(com.navercorp.pinpoint.web.applicationmap.histogram.NodeHistogram) ApplicationTimeHistogram(com.navercorp.pinpoint.web.applicationmap.histogram.ApplicationTimeHistogram) AgentTimeHistogram(com.navercorp.pinpoint.web.applicationmap.histogram.AgentTimeHistogram) ApplicationTimeHistogramBuilder(com.navercorp.pinpoint.web.applicationmap.histogram.ApplicationTimeHistogramBuilder) HashMap(java.util.HashMap) LinkCallDataMap(com.navercorp.pinpoint.web.applicationmap.rawdata.LinkCallDataMap) NodeHistogram(com.navercorp.pinpoint.web.applicationmap.histogram.NodeHistogram) AgentHistogram(com.navercorp.pinpoint.web.applicationmap.rawdata.AgentHistogram) AgentHistogramList(com.navercorp.pinpoint.web.applicationmap.rawdata.AgentHistogramList) Application(com.navercorp.pinpoint.web.vo.Application)

Aggregations

ApplicationTimeHistogram (com.navercorp.pinpoint.web.applicationmap.histogram.ApplicationTimeHistogram)3 Application (com.navercorp.pinpoint.web.vo.Application)3 ApplicationTimeHistogramBuilder (com.navercorp.pinpoint.web.applicationmap.histogram.ApplicationTimeHistogramBuilder)2 NodeHistogram (com.navercorp.pinpoint.web.applicationmap.histogram.NodeHistogram)2 AgentHistogramList (com.navercorp.pinpoint.web.applicationmap.rawdata.AgentHistogramList)2 ObjectWriter (com.fasterxml.jackson.databind.ObjectWriter)1 ServiceType (com.navercorp.pinpoint.common.trace.ServiceType)1 AgentTimeHistogram (com.navercorp.pinpoint.web.applicationmap.histogram.AgentTimeHistogram)1 AgentTimeHistogramBuilder (com.navercorp.pinpoint.web.applicationmap.histogram.AgentTimeHistogramBuilder)1 Histogram (com.navercorp.pinpoint.web.applicationmap.histogram.Histogram)1 AgentHistogram (com.navercorp.pinpoint.web.applicationmap.rawdata.AgentHistogram)1 LinkCallDataMap (com.navercorp.pinpoint.web.applicationmap.rawdata.LinkCallDataMap)1 ResponseTimeViewModel (com.navercorp.pinpoint.web.view.ResponseTimeViewModel)1 Range (com.navercorp.pinpoint.web.vo.Range)1 ResponseTime (com.navercorp.pinpoint.web.vo.ResponseTime)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Test (org.junit.Test)1