use of com.navercorp.pinpoint.common.server.bo.ApiMetaDataBo in project pinpoint by naver.
the class SpanServiceImpl method collisionApiDidMessage.
private String collisionApiDidMessage(int apidId, List<ApiMetaDataBo> apiMetaDataList) {
// TODO need a separate test case to test for apidId collision (probability way too low for easy replication)
StringBuilder sb = new StringBuilder(64);
sb.append("Collision Api DynamicId:");
sb.append(apidId);
sb.append('\n');
for (int i = 0; i < apiMetaDataList.size(); i++) {
if (i != 0) {
sb.append("or\n");
}
ApiMetaDataBo apiMetaDataBo = apiMetaDataList.get(i);
sb.append(getApiInfo(apiMetaDataBo));
}
return sb.toString();
}
use of com.navercorp.pinpoint.common.server.bo.ApiMetaDataBo in project pinpoint by naver.
the class RecordFactory method getApi.
private Api getApi(final SpanAlign align) {
final AnnotationBo annotation = AnnotationUtils.findAnnotationBo(align.getAnnotationBoList(), AnnotationKey.API_METADATA);
if (annotation != null) {
final Api api = new Api();
final ApiMetaDataBo apiMetaData = (ApiMetaDataBo) annotation.getValue();
String apiInfo = getApiInfo(apiMetaData);
api.setTitle(apiInfo);
api.setDescription(apiInfo);
if (apiMetaData.getMethodTypeEnum() == MethodTypeEnum.DEFAULT) {
try {
ApiDescription apiDescription = apiDescriptionParser.parse(api.description);
api.setTitle(apiDescription.getSimpleMethodDescription());
api.setClassName(apiDescription.getSimpleClassName());
} catch (Exception e) {
logger.debug("Failed to api parse. {}", api.description, e);
}
}
api.setMethodTypeEnum(apiMetaData.getMethodTypeEnum());
return api;
} else {
final Api api = new Api();
AnnotationKey apiMetaDataError = getApiMetaDataError(align.getAnnotationBoList());
api.setTitle(apiMetaDataError.getName());
return api;
}
}
use of com.navercorp.pinpoint.common.server.bo.ApiMetaDataBo in project pinpoint by naver.
the class ApiMetaDataMapper method mapRow.
@Override
public List<ApiMetaDataBo> mapRow(Result result, int rowNum) throws Exception {
if (result.isEmpty()) {
return Collections.emptyList();
}
final byte[] rowKey = getOriginalKey(result.getRow());
List<ApiMetaDataBo> apiMetaDataList = new ArrayList<>();
for (Cell cell : result.rawCells()) {
ApiMetaDataBo apiMetaDataBo = new ApiMetaDataBo();
apiMetaDataBo.readRowKey(rowKey);
byte[] qualifier = CellUtil.cloneQualifier(cell);
byte[] value = null;
if (API_METADATA_CF_API_QUALI_SIGNATURE.equals(Bytes.toString(qualifier))) {
value = CellUtil.cloneValue(cell);
} else {
value = qualifier;
}
Buffer buffer = new FixedBuffer(value);
String apiInfo = buffer.readPrefixedString();
int lineNumber = buffer.readInt();
MethodTypeEnum methodTypeEnum = MethodTypeEnum.DEFAULT;
if (buffer.hasRemaining()) {
methodTypeEnum = MethodTypeEnum.valueOf(buffer.readInt());
}
apiMetaDataBo.setApiInfo(apiInfo);
apiMetaDataBo.setLineNumber(lineNumber);
apiMetaDataBo.setMethodTypeEnum(methodTypeEnum);
apiMetaDataList.add(apiMetaDataBo);
if (logger.isDebugEnabled()) {
logger.debug("read apiAnnotation:{}", apiMetaDataBo);
}
}
return apiMetaDataList;
}
use of com.navercorp.pinpoint.common.server.bo.ApiMetaDataBo 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.common.server.bo.ApiMetaDataBo in project pinpoint by naver.
the class HbaseApiMetaDataDao method insert.
@Override
public void insert(TApiMetaData apiMetaData) {
if (logger.isDebugEnabled()) {
logger.debug("insert:{}", apiMetaData);
}
ApiMetaDataBo apiMetaDataBo = new ApiMetaDataBo(apiMetaData.getAgentId(), apiMetaData.getAgentStartTime(), apiMetaData.getApiId());
byte[] rowKey = getDistributedKey(apiMetaDataBo.toRowKey());
final Put put = new Put(rowKey);
final Buffer buffer = new AutomaticBuffer(64);
String api = apiMetaData.getApiInfo();
buffer.putPrefixedString(api);
if (apiMetaData.isSetLine()) {
buffer.putInt(apiMetaData.getLine());
} else {
buffer.putInt(-1);
}
if (apiMetaData.isSetType()) {
buffer.putInt(apiMetaData.getType());
} else {
buffer.putInt(0);
}
final byte[] apiMetaDataBytes = buffer.getBuffer();
put.addColumn(HBaseTables.API_METADATA_CF_API, HBaseTables.API_METADATA_CF_API_QUALI_SIGNATURE, apiMetaDataBytes);
hbaseTemplate.put(HBaseTables.API_METADATA, put);
}
Aggregations