use of com.navercorp.pinpoint.common.server.bo.AnnotationBo in project pinpoint by naver.
the class SpanServiceImpl method transitionSqlId.
private void transitionSqlId(final List<Align> spans) {
this.transitionAnnotation(spans, new AnnotationReplacementCallback() {
@Override
public void replacement(Align align, List<AnnotationBo> annotationBoList) {
AnnotationBo sqlIdAnnotation = findAnnotation(annotationBoList, AnnotationKey.SQL_ID.getCode());
if (sqlIdAnnotation == null) {
return;
}
if (metaDataFilter != null && metaDataFilter.filter(align, MetaData.SQL)) {
AnnotationBo annotationBo = metaDataFilter.createAnnotationBo(align, 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(align.getAgentId(), align.getAgentStartTime(), sqlId);
final int size = sqlMetaDataList.size();
if (size == 0) {
String errorMessage = "SQL-ID not found sqlId:" + sqlId;
AnnotationBo api = new AnnotationBo(AnnotationKey.SQL.getCode(), errorMessage);
annotationBoList.add(api);
} else if (size == 1) {
final SqlMetaDataBo sqlMetaDataBo = sqlMetaDataList.get(0);
if (StringUtils.isEmpty(sqlParam)) {
AnnotationBo sqlMeta = new AnnotationBo(AnnotationKey.SQL_METADATA.getCode(), sqlMetaDataBo.getSql());
annotationBoList.add(sqlMeta);
// AnnotationBo checkFail = checkIdentifier(spanAlign, sqlMetaDataBo);
// if (checkFail != null) {
// // fail
// annotationBoList.add(checkFail);
// return;
// }
AnnotationBo sql = new AnnotationBo(AnnotationKey.SQL.getCode(), StringUtils.trim(sqlMetaDataBo.getSql()));
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(AnnotationKey.SQL_METADATA.getCode(), sqlMetaDataBo.getSql());
annotationBoList.add(sqlMeta);
AnnotationBo sql = new AnnotationBo(AnnotationKey.SQL.getCode(), StringUtils.trim(originalSql));
annotationBoList.add(sql);
}
} else {
// TODO need improvement
String collisionSqlIdCodeMessage = collisionSqlIdCodeMessage(sqlId, sqlMetaDataList);
AnnotationBo api = new AnnotationBo(AnnotationKey.SQL.getCode(), collisionSqlIdCodeMessage);
annotationBoList.add(api);
}
// add if bindValue exists
final String bindValue = sqlValue.getStringValue2();
if (StringUtils.isNotEmpty(bindValue)) {
AnnotationBo bindValueAnnotation = new AnnotationBo(AnnotationKey.SQL_BINDVALUE.getCode(), bindValue);
annotationBoList.add(bindValueAnnotation);
}
}
});
}
use of com.navercorp.pinpoint.common.server.bo.AnnotationBo in project pinpoint by naver.
the class SpanServiceImpl method transitionDynamicApiId.
private void transitionDynamicApiId(List<Align> spans) {
this.transitionAnnotation(spans, new AnnotationReplacementCallback() {
@Override
public void replacement(Align align, List<AnnotationBo> annotationBoList) {
final int apiId = align.getApiId();
if (apiId == 0) {
String apiString = AnnotationUtils.findApiAnnotation(annotationBoList);
// annotation base api
if (apiString != null) {
ApiMetaDataBo apiMetaDataBo = new ApiMetaDataBo(align.getAgentId(), align.getStartTime(), apiId, LineNumber.NO_LINE_NUMBER, MethodTypeEnum.DEFAULT, apiString);
AnnotationBo apiAnnotation = new AnnotationBo(AnnotationKey.API_METADATA.getCode(), apiMetaDataBo);
annotationBoList.add(apiAnnotation);
return;
}
}
// may be able to get a more accurate data using agentIdentifier.
List<ApiMetaDataBo> apiMetaDataList = apiMetaDataDao.getApiMetaData(align.getAgentId(), align.getAgentStartTime(), apiId);
int size = apiMetaDataList.size();
if (size == 0) {
String errorMessage = "API-DynamicID not found. api:" + apiId;
AnnotationBo api = new AnnotationBo(AnnotationKey.ERROR_API_METADATA_NOT_FOUND.getCode(), errorMessage);
annotationBoList.add(api);
} else if (size == 1) {
ApiMetaDataBo apiMetaDataBo = apiMetaDataList.get(0);
AnnotationBo apiMetaData = new AnnotationBo(AnnotationKey.API_METADATA.getCode(), apiMetaDataBo);
annotationBoList.add(apiMetaData);
if (apiMetaDataBo.getMethodTypeEnum() == MethodTypeEnum.DEFAULT) {
String apiInfo = getApiInfo(apiMetaDataBo);
AnnotationBo apiAnnotation = new AnnotationBo(AnnotationKey.API.getCode(), apiInfo);
annotationBoList.add(apiAnnotation);
} else {
String apiTagInfo = getApiTagInfo(apiMetaDataBo);
AnnotationBo apiAnnotation = new AnnotationBo(AnnotationKey.API_TAG.getCode(), apiTagInfo);
annotationBoList.add(apiAnnotation);
}
} else {
String collisionMessage = collisionApiDidMessage(apiId, apiMetaDataList);
AnnotationBo apiAnnotation = new AnnotationBo(AnnotationKey.ERROR_API_METADATA_DID_COLLSION.getCode(), collisionMessage);
annotationBoList.add(apiAnnotation);
}
}
});
}
use of com.navercorp.pinpoint.common.server.bo.AnnotationBo in project pinpoint by naver.
the class TransactionInfoServiceImpl method getDisplayArgument0.
private AnnotationBo getDisplayArgument0(Event event) {
// TODO needs a more generalized implementation for Arcus
List<AnnotationBo> list = event.getAnnotationBoList();
if (list == null) {
return null;
}
final AnnotationKeyMatcher matcher = annotationKeyMatcherService.findAnnotationKeyMatcher(event.getServiceType());
if (matcher == null) {
return null;
}
for (AnnotationBo annotation : list) {
int key = annotation.getKey();
if (matcher.matches(key)) {
return annotation;
}
}
return null;
}
use of com.navercorp.pinpoint.common.server.bo.AnnotationBo in project pinpoint by naver.
the class SpanFactory method bind.
private void bind(SpanEventBo spanEvent, TSpanEvent tSpanEvent) {
spanEvent.setSequence(tSpanEvent.getSequence());
spanEvent.setStartElapsed(tSpanEvent.getStartElapsed());
spanEvent.setEndElapsed(tSpanEvent.getEndElapsed());
spanEvent.setRpc(tSpanEvent.getRpc());
spanEvent.setServiceType(tSpanEvent.getServiceType());
spanEvent.setDestinationId(tSpanEvent.getDestinationId());
spanEvent.setEndPoint(tSpanEvent.getEndPoint());
spanEvent.setApiId(tSpanEvent.getApiId());
if (tSpanEvent.isSetDepth()) {
spanEvent.setDepth(tSpanEvent.getDepth());
}
if (tSpanEvent.isSetNextSpanId()) {
spanEvent.setNextSpanId(tSpanEvent.getNextSpanId());
}
List<AnnotationBo> annotationList = buildAnnotationList(tSpanEvent.getAnnotations());
spanEvent.setAnnotationBoList(annotationList);
final TIntStringValue exceptionInfo = tSpanEvent.getExceptionInfo();
if (exceptionInfo != null) {
spanEvent.setExceptionInfo(exceptionInfo.getIntValue(), exceptionInfo.getStringValue());
}
if (tSpanEvent.isSetNextAsyncId()) {
spanEvent.setNextAsyncId(tSpanEvent.getNextAsyncId());
}
// async id
// if (localAsyncId == null) {
// if (tSpanEvent.isSetAsyncId()) {
// spanEvent.setAsyncId(tSpanEvent.getAsyncId());
// }
// if (tSpanEvent.isSetAsyncSequence()) {
// spanEvent.setAsyncSequence(tSpanEvent.getAsyncSequence());
// }
// } else {
// spanEvent.setAsyncId(localAsyncId.getAsyncId());
// spanEvent.setAsyncSequence((short) localAsyncId.getSequence());
// }
}
use of com.navercorp.pinpoint.common.server.bo.AnnotationBo in project pinpoint by naver.
the class SpanFactory method buildAnnotationList.
private List<AnnotationBo> buildAnnotationList(List<TAnnotation> tAnnotationList) {
if (tAnnotationList == null) {
return new ArrayList<>();
}
List<AnnotationBo> boList = new ArrayList<>(tAnnotationList.size());
for (TAnnotation tAnnotation : tAnnotationList) {
final AnnotationBo annotationBo = newAnnotationBo(tAnnotation);
boList.add(annotationBo);
}
boList.sort(AnnotationComparator.INSTANCE);
return boList;
}
Aggregations