Search in sources :

Example 31 with AnnotationBo

use of com.navercorp.pinpoint.common.server.bo.AnnotationBo in project pinpoint by naver.

the class SpanDecoderV0 method readFirstSpanEvent.

private SpanEventBo readFirstSpanEvent(Buffer buffer, SpanEventBo firstSpanEvent, SpanDecodingContext decodingContext) {
    SpanEventBitField bitField = new SpanEventBitField(buffer.readByte());
    firstSpanEvent.setStartElapsed(buffer.readVInt());
    firstSpanEvent.setEndElapsed(buffer.readVInt());
    firstSpanEvent.setSequence(buffer.readShort());
    firstSpanEvent.setDepth(buffer.readSVInt());
    firstSpanEvent.setServiceType(buffer.readShort());
    if (bitField.isSetRpc()) {
        firstSpanEvent.setRpc(buffer.readPrefixedString());
    }
    if (bitField.isSetEndPoint()) {
        firstSpanEvent.setEndPoint(buffer.readPrefixedString());
    }
    if (bitField.isSetDestinationId()) {
        firstSpanEvent.setDestinationId(buffer.readPrefixedString());
    }
    firstSpanEvent.setApiId(buffer.readSVInt());
    if (bitField.isSetNextSpanId()) {
        firstSpanEvent.setNextSpanId(buffer.readLong());
    }
    if (bitField.isSetHasException()) {
        int exceptionId = buffer.readSVInt();
        String exceptionMessage = buffer.readPrefixedString();
        firstSpanEvent.setExceptionInfo(exceptionId, exceptionMessage);
    }
    if (bitField.isSetAnnotation()) {
        List<AnnotationBo> annotationBoList = readAnnotationList(buffer, decodingContext);
        firstSpanEvent.setAnnotationBoList(annotationBoList);
    }
    if (bitField.isSetNextAsyncId()) {
        firstSpanEvent.setNextAsyncId(buffer.readSVInt());
    }
    //        }
    return firstSpanEvent;
}
Also used : SpanEventBitField(com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.bitfield.SpanEventBitField) AnnotationBo(com.navercorp.pinpoint.common.server.bo.AnnotationBo)

Example 32 with AnnotationBo

use of com.navercorp.pinpoint.common.server.bo.AnnotationBo in project pinpoint by naver.

the class CorruptedSpanAlignFactory method get.

public SpanAlign get(final String title, final SpanBo span, final SpanEventBo spanEvent) {
    final SpanEventBo missedEvent = new SpanEventBo();
    // TODO use invalid event information ?
    missedEvent.setStartElapsed(spanEvent.getStartElapsed());
    missedEvent.setEndElapsed(spanEvent.getEndElapsed());
    missedEvent.setServiceType(ServiceType.COLLECTOR.getCode());
    List<AnnotationBo> annotations = new ArrayList<>();
    ApiMetaDataBo apiMetaData = new ApiMetaDataBo();
    apiMetaData.setLineNumber(-1);
    apiMetaData.setApiInfo("...");
    apiMetaData.setMethodTypeEnum(MethodTypeEnum.CORRUPTED);
    final AnnotationBo apiMetaDataAnnotation = new AnnotationBo();
    apiMetaDataAnnotation.setKey(AnnotationKey.API_METADATA.getCode());
    apiMetaDataAnnotation.setValue(apiMetaData);
    annotations.add(apiMetaDataAnnotation);
    final AnnotationBo argumentAnnotation = new AnnotationBo();
    argumentAnnotation.setKey(AnnotationKeyUtils.getArgs(0).getCode());
    if (System.currentTimeMillis() - span.getStartTime() < timeoutMillisec) {
        argumentAnnotation.setValue("Corrupted(waiting for packet) ");
    } else {
        if (title != null) {
            argumentAnnotation.setValue("Corrupted(" + title + ")");
        } else {
            argumentAnnotation.setValue("Corrupted");
        }
    }
    annotations.add(argumentAnnotation);
    missedEvent.setAnnotationBoList(annotations);
    return new SpanAlign(span, missedEvent);
}
Also used : AnnotationBo(com.navercorp.pinpoint.common.server.bo.AnnotationBo) ArrayList(java.util.ArrayList) ApiMetaDataBo(com.navercorp.pinpoint.common.server.bo.ApiMetaDataBo) SpanEventBo(com.navercorp.pinpoint.common.server.bo.SpanEventBo)

Example 33 with AnnotationBo

use of com.navercorp.pinpoint.common.server.bo.AnnotationBo in project pinpoint by naver.

the class SpanMapper method mapRow.

@Override
public List<SpanBo> mapRow(Result result, int rowNum) throws Exception {
    if (result.isEmpty()) {
        return Collections.emptyList();
    }
    byte[] rowKey = result.getRow();
    final TransactionId transactionId = this.rowKeyDecoder.decodeRowKey(rowKey);
    final Cell[] rawCells = result.rawCells();
    Map<AgentKey, SpanBo> spanMap = new LinkedHashMap<>();
    ListMultimap<AgentKey, SpanEventBo> spanEventBoListMap = ArrayListMultimap.create();
    ListMultimap<Long, AnnotationBo> annotationBoListMap = ArrayListMultimap.create();
    final SpanDecodingContext decodingContext = new SpanDecodingContext();
    decodingContext.setTransactionId(transactionId);
    for (Cell cell : rawCells) {
        decodingContext.setCollectorAcceptedTime(cell.getTimestamp());
        // only if family name is "span"
        if (CellUtil.matchingFamily(cell, HBaseTables.TRACES_CF_SPAN)) {
            Buffer qualifierBuffer = new OffsetFixedBuffer(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength());
            Buffer valueBuffer = new OffsetFixedBuffer(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
            final SpanBo spanBo = spanDecoder.decodeSpanBo(qualifierBuffer, valueBuffer, decodingContext);
            AgentKey agentKey = newAgentKey(spanBo);
            spanMap.put(agentKey, spanBo);
        } else if (CellUtil.matchingFamily(cell, HBaseTables.TRACES_CF_TERMINALSPAN)) {
            final Buffer qualifier = new OffsetFixedBuffer(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength());
            final Buffer valueBuffer = new OffsetFixedBuffer(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
            SpanEventBo spanEventBo = spanDecoder.decodeSpanEventBo(qualifier, valueBuffer, decodingContext);
            AgentKey agentKey = newAgentKey(decodingContext);
            spanEventBoListMap.put(agentKey, spanEventBo);
        } else if (CellUtil.matchingFamily(cell, HBaseTables.TRACES_CF_ANNOTATION)) {
            final Buffer qualifier = new OffsetFixedBuffer(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength());
            final Buffer valueBuffer = new OffsetFixedBuffer(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
            List<AnnotationBo> annotationBoList = annotationBoDecoder.decode(qualifier, valueBuffer, decodingContext);
            if (CollectionUtils.isNotEmpty(annotationBoList)) {
                long spanId = decodingContext.getSpanId();
                annotationBoListMap.putAll(spanId, annotationBoList);
            }
        }
        spanDecoder.next(decodingContext);
    }
    decodingContext.finish();
    for (Map.Entry<AgentKey, SpanEventBo> spanBoEntry : spanEventBoListMap.entries()) {
        final AgentKey agentKey = spanBoEntry.getKey();
        SpanBo spanBo = spanMap.get(agentKey);
        if (spanBo != null) {
            SpanEventBo value = spanBoEntry.getValue();
            spanBo.addSpanEvent(value);
        } else {
            if (logger.isInfoEnabled()) {
                logger.info("Span not exist spanId:{} spanEvent:{}", spanBoEntry.getKey(), spanBoEntry.getValue());
            }
        }
    }
    List<SpanBo> spanList = Lists.newArrayList(spanMap.values());
    if (!annotationBoListMap.isEmpty()) {
        addAnnotation(spanList, annotationBoListMap);
    }
    return spanList;
}
Also used : Buffer(com.navercorp.pinpoint.common.buffer.Buffer) OffsetFixedBuffer(com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer) SpanDecodingContext(com.navercorp.pinpoint.common.server.bo.serializer.trace.v1.SpanDecodingContext) OffsetFixedBuffer(com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer) SpanBo(com.navercorp.pinpoint.common.server.bo.SpanBo) TransactionId(com.navercorp.pinpoint.common.util.TransactionId) AnnotationBo(com.navercorp.pinpoint.common.server.bo.AnnotationBo) Cell(org.apache.hadoop.hbase.Cell) SpanEventBo(com.navercorp.pinpoint.common.server.bo.SpanEventBo)

Example 34 with AnnotationBo

use of com.navercorp.pinpoint.common.server.bo.AnnotationBo in project pinpoint by naver.

the class SpanMapper method addAnnotation.

private void addAnnotation(List<SpanBo> spanList, ListMultimap<Long, AnnotationBo> annotationMap) {
    for (SpanBo spanBo : spanList) {
        long spanId = spanBo.getSpanId();
        List<AnnotationBo> anoList = annotationMap.get(spanId);
        spanBo.setAnnotationBoList(anoList);
    }
}
Also used : AnnotationBo(com.navercorp.pinpoint.common.server.bo.AnnotationBo) SpanBo(com.navercorp.pinpoint.common.server.bo.SpanBo)

Example 35 with AnnotationBo

use of com.navercorp.pinpoint.common.server.bo.AnnotationBo in project pinpoint by naver.

the class SpanServiceImpl method transitionAnnotation.

private void transitionAnnotation(List<Align> spans, AnnotationReplacementCallback annotationReplacementCallback) {
    for (Align align : spans) {
        List<AnnotationBo> annotationBoList = align.getAnnotationBoList();
        if (annotationBoList == null) {
            annotationBoList = new ArrayList<>();
            align.setAnnotationBoList(annotationBoList);
        }
        annotationReplacementCallback.replacement(align, annotationBoList);
    }
}
Also used : AnnotationBo(com.navercorp.pinpoint.common.server.bo.AnnotationBo) Align(com.navercorp.pinpoint.web.calltree.span.Align)

Aggregations

AnnotationBo (com.navercorp.pinpoint.common.server.bo.AnnotationBo)55 ArrayList (java.util.ArrayList)17 SpanEventBo (com.navercorp.pinpoint.common.server.bo.SpanEventBo)14 SpanBo (com.navercorp.pinpoint.common.server.bo.SpanBo)13 ApiMetaDataBo (com.navercorp.pinpoint.common.server.bo.ApiMetaDataBo)7 Test (org.junit.Test)7 List (java.util.List)6 Buffer (com.navercorp.pinpoint.common.buffer.Buffer)5 TransactionId (com.navercorp.pinpoint.common.profiler.util.TransactionId)5 SpanEventBitField (com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.bitfield.SpanEventBitField)5 AnnotationKey (com.navercorp.pinpoint.common.trace.AnnotationKey)5 Align (com.navercorp.pinpoint.web.calltree.span.Align)4 SpanAlign (com.navercorp.pinpoint.web.calltree.span.SpanAlign)4 ByteBuffer (java.nio.ByteBuffer)4 AutomaticBuffer (com.navercorp.pinpoint.common.buffer.AutomaticBuffer)3 SpanBitFiled (com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.bitfield.SpanBitFiled)3 ServiceType (com.navercorp.pinpoint.common.trace.ServiceType)3 OffsetFixedBuffer (com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer)2 SqlMetaDataBo (com.navercorp.pinpoint.common.server.bo.SqlMetaDataBo)2 StringMetaDataBo (com.navercorp.pinpoint.common.server.bo.StringMetaDataBo)2