use of com.navercorp.pinpoint.web.calltree.span.SpanAlign in project pinpoint by naver.
the class RecordFactory method get.
public Record get(final CallTreeNode node, final String argument) {
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, api.getTitle(), argument, align.getStartTime(), align.getElapsed(), align.getGap(), align.getAgentId(), align.getApplicationId(), registry.findServiceType(align.getServiceType()), align.getDestinationId(), align.hasChild(), false, align.getTransactionId(), align.getSpanId(), align.getExecutionMilliseconds(), api.getMethodTypeEnum(), true);
record.setSimpleClassName(api.getClassName());
record.setFullApiDescription(api.getDescription());
return record;
}
use of com.navercorp.pinpoint.web.calltree.span.SpanAlign in project pinpoint by naver.
the class SpanServiceImpl method transitionException.
private void transitionException(List<SpanAlign> spanAlignList) {
for (SpanAlign spanAlign : spanAlignList) {
if (spanAlign.hasException()) {
StringMetaDataBo stringMetaData = selectStringMetaData(spanAlign.getAgentId(), spanAlign.getExceptionId(), spanAlign.getAgentStartTime());
spanAlign.setExceptionClass(stringMetaData.getStringValue());
}
}
}
use of com.navercorp.pinpoint.web.calltree.span.SpanAlign in project pinpoint by naver.
the class SpanServiceImpl method transitionAnnotation.
private void transitionAnnotation(List<SpanAlign> spans, AnnotationReplacementCallback annotationReplacementCallback) {
for (SpanAlign spanAlign : spans) {
List<AnnotationBo> annotationBoList = spanAlign.getAnnotationBoList();
if (annotationBoList == null) {
annotationBoList = new ArrayList<>();
spanAlign.setAnnotationBoList(annotationBoList);
}
annotationReplacementCallback.replacement(spanAlign, annotationBoList);
}
}
use of com.navercorp.pinpoint.web.calltree.span.SpanAlign in project pinpoint by naver.
the class SpanServiceImpl method transitionSqlId.
private void transitionSqlId(final List<SpanAlign> spans) {
this.transitionAnnotation(spans, new AnnotationReplacementCallback() {
@Override
public void replacement(SpanAlign spanAlign, List<AnnotationBo> annotationBoList) {
AnnotationBo sqlIdAnnotation = findAnnotation(annotationBoList, AnnotationKey.SQL_ID.getCode());
if (sqlIdAnnotation == null) {
return;
}
if (metaDataFilter != null && metaDataFilter.filter(spanAlign, MetaData.SQL)) {
AnnotationBo annotationBo = metaDataFilter.createAnnotationBo(spanAlign, MetaData.SQL);
annotationBoList.add(annotationBo);
return;
}
// value of sqlId's annotation contains multiple values.
final IntStringStringValue sqlValue = (IntStringStringValue) sqlIdAnnotation.getValue();
final int sqlId = sqlValue.getIntValue();
final String sqlParam = sqlValue.getStringValue1();
final List<SqlMetaDataBo> sqlMetaDataList = sqlMetaDataDao.getSqlMetaData(spanAlign.getAgentId(), spanAlign.getAgentStartTime(), sqlId);
final int size = sqlMetaDataList.size();
if (size == 0) {
AnnotationBo api = new AnnotationBo();
api.setKey(AnnotationKey.SQL.getCode());
api.setValue("SQL-ID not found sqlId:" + sqlId);
annotationBoList.add(api);
} else if (size == 1) {
final SqlMetaDataBo sqlMetaDataBo = sqlMetaDataList.get(0);
if (StringUtils.isEmpty(sqlParam)) {
AnnotationBo sqlMeta = new AnnotationBo();
sqlMeta.setKey(AnnotationKey.SQL_METADATA.getCode());
sqlMeta.setValue(sqlMetaDataBo.getSql());
annotationBoList.add(sqlMeta);
// AnnotationBo checkFail = checkIdentifier(spanAlign, sqlMetaDataBo);
// if (checkFail != null) {
// // fail
// annotationBoList.add(checkFail);
// return;
// }
AnnotationBo sql = new AnnotationBo();
sql.setKey(AnnotationKey.SQL.getCode());
sql.setValue(sqlMetaDataBo.getSql().trim());
annotationBoList.add(sql);
} else {
logger.debug("sqlMetaDataBo:{}", sqlMetaDataBo);
final String outputParams = sqlParam;
List<String> parsedOutputParams = outputParameterParser.parseOutputParameter(outputParams);
logger.debug("outputPrams:{}, parsedOutputPrams:{}", outputParams, parsedOutputParams);
String originalSql = sqlParser.combineOutputParams(sqlMetaDataBo.getSql(), parsedOutputParams);
logger.debug("outputPrams{}, originalSql:{}", outputParams, originalSql);
AnnotationBo sqlMeta = new AnnotationBo();
sqlMeta.setKey(AnnotationKey.SQL_METADATA.getCode());
sqlMeta.setValue(sqlMetaDataBo.getSql());
annotationBoList.add(sqlMeta);
AnnotationBo sql = new AnnotationBo();
sql.setKey(AnnotationKey.SQL.getCode());
sql.setValue(originalSql.trim());
annotationBoList.add(sql);
}
} else {
// TODO need improvement
AnnotationBo api = new AnnotationBo();
api.setKey(AnnotationKey.SQL.getCode());
api.setValue(collisionSqlIdCodeMessage(sqlId, sqlMetaDataList));
annotationBoList.add(api);
}
// add if bindValue exists
final String bindValue = sqlValue.getStringValue2();
if (StringUtils.isNotEmpty(bindValue)) {
AnnotationBo bindValueAnnotation = new AnnotationBo();
bindValueAnnotation.setKey(AnnotationKey.SQL_BINDVALUE.getCode());
bindValueAnnotation.setValue(bindValue);
annotationBoList.add(bindValueAnnotation);
}
}
});
}
use of com.navercorp.pinpoint.web.calltree.span.SpanAlign in project pinpoint by naver.
the class TransactionInfoServiceImpl method createRecordSet.
@Override
public RecordSet createRecordSet(CallTreeIterator callTreeIterator, long focusTimestamp, String agentId, long spanId) {
if (callTreeIterator == null) {
throw new NullPointerException("callTreeIterator must not be null");
}
RecordSet recordSet = new RecordSet();
final List<SpanAlign> spanAlignList = callTreeIterator.values();
// finds and marks the viewPoint.base on focusTimestamp.
// focusTimestamp is needed to determine which span to use as reference when there are more than 2 spans making up a transaction.
// for cases where focus cannot be found due to an error, a separate marker is needed.
// TODO potential error - because server time is used, there may be more than 2 focusTime due to differences in server times.
SpanAlign viewPointSpanAlign = findViewPoint(spanAlignList, focusTimestamp, agentId, spanId);
// FIXME patched temporarily for cases where focusTimeSpanBo is not found. Need a more complete solution.
if (viewPointSpanAlign != null) {
recordSet.setAgentId(viewPointSpanAlign.getAgentId());
recordSet.setApplicationId(viewPointSpanAlign.getApplicationId());
final String applicationName = getRpcArgument(viewPointSpanAlign);
recordSet.setApplicationName(applicationName);
}
// find the startTime to use as reference
long startTime = getStartTime(spanAlignList);
recordSet.setStartTime(startTime);
// find the endTime to use as reference
long endTime = getEndTime(spanAlignList);
recordSet.setEndTime(endTime);
recordSet.setLoggingTransactionInfo(findIsLoggingTransactionInfo(spanAlignList));
final SpanAlignPopulate spanAlignPopulate = new SpanAlignPopulate();
List<Record> recordList = spanAlignPopulate.populateSpanRecord(callTreeIterator);
logger.debug("RecordList:{}", recordList);
if (viewPointSpanAlign != null) {
// mark the record to be used as focus
long beginTimeStamp = viewPointSpanAlign.getStartTime();
markFocusRecord(recordList, viewPointSpanAlign);
recordSet.setBeginTimestamp(beginTimeStamp);
}
recordSet.setRecordList(recordList);
return recordSet;
}
Aggregations