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;
}
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);
}
}
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());
}
}
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();
}
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;
}
}));
}
Aggregations