use of com.navercorp.pinpoint.web.calltree.span.SpanAlign in project pinpoint by naver.
the class SpanServiceImpl method transitionCachedString.
private void transitionCachedString(List<SpanAlign> spans) {
this.transitionAnnotation(spans, new AnnotationReplacementCallback() {
@Override
public void replacement(SpanAlign spanAlign, List<AnnotationBo> annotationBoList) {
List<AnnotationBo> cachedStringAnnotation = findCachedStringAnnotation(annotationBoList);
if (cachedStringAnnotation.isEmpty()) {
return;
}
for (AnnotationBo annotationBo : cachedStringAnnotation) {
final int cachedArgsKey = annotationBo.getKey();
int stringMetaDataId = (Integer) annotationBo.getValue();
List<StringMetaDataBo> stringMetaList = stringMetaDataDao.getStringMetaData(spanAlign.getAgentId(), spanAlign.getAgentStartTime(), stringMetaDataId);
int size = stringMetaList.size();
if (size == 0) {
logger.warn("StringMetaData not Found {}/{}/{}", spanAlign.getAgentId(), stringMetaDataId, spanAlign.getAgentStartTime());
AnnotationBo api = new AnnotationBo();
api.setKey(AnnotationKey.ERROR_API_METADATA_NOT_FOUND.getCode());
api.setValue("CACHED-STRING-ID not found. stringId:" + cachedArgsKey);
annotationBoList.add(api);
} else if (size >= 1) {
// key collision shouldn't really happen (probability too low)
StringMetaDataBo stringMetaDataBo = stringMetaList.get(0);
AnnotationBo stringMetaData = new AnnotationBo();
stringMetaData.setKey(AnnotationKeyUtils.cachedArgsToArgs(cachedArgsKey));
stringMetaData.setValue(stringMetaDataBo.getStringValue());
annotationBoList.add(stringMetaData);
if (size > 1) {
logger.warn("stringMetaData size not 1 :{}", stringMetaList);
}
}
}
}
});
}
use of com.navercorp.pinpoint.web.calltree.span.SpanAlign in project pinpoint by naver.
the class SpanServiceImpl method selectSpan.
@Override
public SpanResult selectSpan(TransactionId transactionId, long selectedSpanHint) {
if (transactionId == null) {
throw new NullPointerException("transactionId must not be null");
}
final List<SpanBo> spans = traceDao.selectSpan(transactionId);
if (CollectionUtils.isEmpty(spans)) {
return new SpanResult(SpanAligner2.FAIL_MATCH, new CallTreeIterator(null));
}
final SpanResult result = order(spans, selectedSpanHint);
final CallTreeIterator callTreeIterator = result.getCallTree();
final List<SpanAlign> values = callTreeIterator.values();
transitionDynamicApiId(values);
transitionSqlId(values);
transitionCachedString(values);
transitionException(values);
// TODO need to at least show the row data when root span is not found.
return result;
}
use of com.navercorp.pinpoint.web.calltree.span.SpanAlign in project pinpoint by naver.
the class SpanServiceImpl method transitionDynamicApiId.
private void transitionDynamicApiId(List<SpanAlign> spans) {
this.transitionAnnotation(spans, new AnnotationReplacementCallback() {
@Override
public void replacement(SpanAlign spanAlign, List<AnnotationBo> annotationBoList) {
final int apiId = spanAlign.getApiId();
if (apiId == 0) {
String apiString = AnnotationUtils.findApiAnnotation(annotationBoList);
// annotation base api
if (apiString != null) {
ApiMetaDataBo apiMetaDataBo = new ApiMetaDataBo(spanAlign.getAgentId(), spanAlign.getStartTime(), apiId);
apiMetaDataBo.setApiInfo(apiString);
apiMetaDataBo.setLineNumber(-1);
apiMetaDataBo.setMethodTypeEnum(MethodTypeEnum.DEFAULT);
AnnotationBo apiAnnotation = new AnnotationBo();
apiAnnotation.setKey(AnnotationKey.API_METADATA.getCode());
apiAnnotation.setValue(apiMetaDataBo);
annotationBoList.add(apiAnnotation);
return;
}
}
// may be able to get a more accurate data using agentIdentifier.
List<ApiMetaDataBo> apiMetaDataList = apiMetaDataDao.getApiMetaData(spanAlign.getAgentId(), spanAlign.getAgentStartTime(), apiId);
int size = apiMetaDataList.size();
if (size == 0) {
AnnotationBo api = new AnnotationBo();
api.setKey(AnnotationKey.ERROR_API_METADATA_NOT_FOUND.getCode());
api.setValue("API-DynamicID not found. api:" + apiId);
annotationBoList.add(api);
} else if (size == 1) {
ApiMetaDataBo apiMetaDataBo = apiMetaDataList.get(0);
AnnotationBo apiMetaData = new AnnotationBo();
apiMetaData.setKey(AnnotationKey.API_METADATA.getCode());
apiMetaData.setValue(apiMetaDataBo);
annotationBoList.add(apiMetaData);
if (apiMetaDataBo.getMethodTypeEnum() == MethodTypeEnum.DEFAULT) {
AnnotationBo apiAnnotation = new AnnotationBo();
apiAnnotation.setKey(AnnotationKey.API.getCode());
String apiInfo = getApiInfo(apiMetaDataBo);
apiAnnotation.setValue(apiInfo);
annotationBoList.add(apiAnnotation);
} else {
AnnotationBo apiAnnotation = new AnnotationBo();
apiAnnotation.setKey(AnnotationKey.API_TAG.getCode());
apiAnnotation.setValue(getApiTagInfo(apiMetaDataBo));
annotationBoList.add(apiAnnotation);
}
} else {
AnnotationBo apiAnnotation = new AnnotationBo();
apiAnnotation.setKey(AnnotationKey.ERROR_API_METADATA_DID_COLLSION.getCode());
String collisionMessage = collisionApiDidMessage(apiId, apiMetaDataList);
apiAnnotation.setValue(collisionMessage);
annotationBoList.add(apiAnnotation);
}
}
});
}
use of com.navercorp.pinpoint.web.calltree.span.SpanAlign in project pinpoint by naver.
the class RecordFactory method getFilteredRecord.
public Record getFilteredRecord(final CallTreeNode node, String apiTitle) {
final SpanAlign align = node.getValue();
align.setId(getNextId());
final int parentId = getParentId(node);
// Api api = getApi(align);
final Record record = new Record(align.getDepth(), align.getId(), parentId, true, apiTitle, "", align.getStartTime(), align.getElapsed(), align.getGap(), "UNKNOWN", align.getApplicationId(), ServiceType.UNKNOWN, "", false, false, align.getTransactionId(), align.getSpanId(), align.getExecutionMilliseconds(), MethodTypeEnum.DEFAULT, false);
return record;
}
Aggregations