use of com.navercorp.pinpoint.common.util.IntStringStringValue 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);
}
}
});
}
Aggregations