Search in sources :

Example 1 with ApiMetaDataBo

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();
}
Also used : ApiMetaDataBo(com.navercorp.pinpoint.common.server.bo.ApiMetaDataBo)

Example 2 with ApiMetaDataBo

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;
    }
}
Also used : AnnotationBo(com.navercorp.pinpoint.common.server.bo.AnnotationBo) AnnotationKey(com.navercorp.pinpoint.common.trace.AnnotationKey) ApiMetaDataBo(com.navercorp.pinpoint.common.server.bo.ApiMetaDataBo) ApiDescription(com.navercorp.pinpoint.common.util.ApiDescription)

Example 3 with ApiMetaDataBo

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;
}
Also used : FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) Buffer(com.navercorp.pinpoint.common.buffer.Buffer) FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) ArrayList(java.util.ArrayList) MethodTypeEnum(com.navercorp.pinpoint.common.server.bo.MethodTypeEnum) ApiMetaDataBo(com.navercorp.pinpoint.common.server.bo.ApiMetaDataBo) Cell(org.apache.hadoop.hbase.Cell)

Example 4 with ApiMetaDataBo

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);
            }
        }
    });
}
Also used : SpanAlign(com.navercorp.pinpoint.web.calltree.span.SpanAlign) AnnotationBo(com.navercorp.pinpoint.common.server.bo.AnnotationBo) ApiMetaDataBo(com.navercorp.pinpoint.common.server.bo.ApiMetaDataBo) ArrayList(java.util.ArrayList) List(java.util.List)

Example 5 with ApiMetaDataBo

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);
}
Also used : Buffer(com.navercorp.pinpoint.common.buffer.Buffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) ApiMetaDataBo(com.navercorp.pinpoint.common.server.bo.ApiMetaDataBo) Put(org.apache.hadoop.hbase.client.Put)

Aggregations

ApiMetaDataBo (com.navercorp.pinpoint.common.server.bo.ApiMetaDataBo)7 AnnotationBo (com.navercorp.pinpoint.common.server.bo.AnnotationBo)3 ArrayList (java.util.ArrayList)3 Buffer (com.navercorp.pinpoint.common.buffer.Buffer)2 AutomaticBuffer (com.navercorp.pinpoint.common.buffer.AutomaticBuffer)1 FixedBuffer (com.navercorp.pinpoint.common.buffer.FixedBuffer)1 MethodTypeEnum (com.navercorp.pinpoint.common.server.bo.MethodTypeEnum)1 SpanEventBo (com.navercorp.pinpoint.common.server.bo.SpanEventBo)1 AnnotationKey (com.navercorp.pinpoint.common.trace.AnnotationKey)1 ApiDescription (com.navercorp.pinpoint.common.util.ApiDescription)1 SpanAlign (com.navercorp.pinpoint.web.calltree.span.SpanAlign)1 List (java.util.List)1 Cell (org.apache.hadoop.hbase.Cell)1 Get (org.apache.hadoop.hbase.client.Get)1 Put (org.apache.hadoop.hbase.client.Put)1 Cacheable (org.springframework.cache.annotation.Cacheable)1