Search in sources :

Example 56 with SpanEventBo

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

the class SpanAligner2 method extractAsyncSpanEvent.

SpanAsyncEventMap extractAsyncSpanEvent(final List<SpanEventBo> spanEventBoList) {
    final SpanAsyncEventMap spanAsyncEventMap = new SpanAsyncEventMap();
    if (spanEventBoList == null) {
        return spanAsyncEventMap;
    }
    final List<SpanEventBo> removeList = new ArrayList<>();
    for (SpanEventBo spanEvent : spanEventBoList) {
        if (spanAsyncEventMap.add(spanEvent)) {
            removeList.add(spanEvent);
        }
    }
    spanAsyncEventMap.sort();
    // clear
    spanEventBoList.removeAll(removeList);
    return spanAsyncEventMap;
}
Also used : SpanEventBo(com.navercorp.pinpoint.common.server.bo.SpanEventBo)

Example 57 with SpanEventBo

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

the class SpanAligner2 method populateSubTree.

private void populateSubTree(final CallTree tree, final SpanBo span, final List<SpanEventBo> spanEventBoList, SpanAsyncEventMap asyncSpanEventMap) {
    if (spanEventBoList == null) {
        return;
    }
    for (SpanEventBo spanEventBo : spanEventBoList) {
        if (logger.isDebugEnabled()) {
            logger.debug("Align seq={}, depth={}, async={}, event={}", spanEventBo.getSequence(), spanEventBo.getDepth(), spanEventBo.isAsync(), spanEventBo);
        }
        final SpanAlign spanEventAlign = new SpanAlign(span, spanEventBo);
        try {
            tree.add(spanEventBo.getDepth(), spanEventAlign);
        } catch (CorruptedSpanCallTreeNodeException e) {
            logger.warn("Find corrupted span event.", e);
            CorruptedSpanAlignFactory factory = new CorruptedSpanAlignFactory();
            final CallTree subTree = new SpanCallTree(factory.get(e.getTitle(), span, spanEventBo));
            tree.add(subTree);
            return;
        }
        final long nextSpanId = spanEventBo.getNextSpanId();
        final List<SpanBo> nextSpanBoList = spanIdMap.remove(nextSpanId);
        if (nextSpanId != ROOT && nextSpanBoList != null) {
            final SpanBo nextSpanBo = getNextSpan(span, spanEventBo, nextSpanBoList);
            if (nextSpanBo != null) {
                final CallTree subTree = createSpanCallTree(nextSpanBo);
                tree.add(subTree);
            } else {
                logger.debug("nextSpanId not found. {}", nextSpanId);
            }
        }
        final int nextAsyncId = spanEventBo.getNextAsyncId();
        for (List<SpanEventBo> list : asyncSpanEventMap.get(nextAsyncId)) {
            final CallTree subTree = createAsyncSpanCallTree(span, list, asyncSpanEventMap);
            tree.add(subTree);
        }
    }
}
Also used : SpanBo(com.navercorp.pinpoint.common.server.bo.SpanBo) SpanEventBo(com.navercorp.pinpoint.common.server.bo.SpanEventBo)

Example 58 with SpanEventBo

use of com.navercorp.pinpoint.common.server.bo.SpanEventBo 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 59 with SpanEventBo

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

the class SpanMapperV2 method sortSpanEvent.

private void sortSpanEvent(List<SpanBo> spanBoList) {
    for (SpanBo spanBo : spanBoList) {
        List<SpanEventBo> spanEventBoList = spanBo.getSpanEventBoList();
        Collections.sort(spanEventBoList, SpanEventComparator.INSTANCE);
    }
}
Also used : SpanBo(com.navercorp.pinpoint.common.server.bo.SpanBo) SpanEventBo(com.navercorp.pinpoint.common.server.bo.SpanEventBo)

Example 60 with SpanEventBo

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

the class RpcURLPatternFilter method accept.

@Override
public boolean accept(List<SpanBo> fromSpanList) {
    for (SpanBo spanBo : fromSpanList) {
        List<SpanEventBo> spanEventBoList = spanBo.getSpanEventBoList();
        if (spanEventBoList == null) {
            return REJECT;
        }
        for (SpanEventBo event : spanEventBoList) {
            final ServiceType eventServiceType = serviceTypeRegistryService.findServiceType(event.getServiceType());
            if (!eventServiceType.isRpcClient()) {
                continue;
            }
            if (!eventServiceType.isRecordStatistics()) {
                continue;
            }
            //                http://api.domain.com/test/ArticleList.do
            //                slice url ->/test/ArticleList.do
            final List<AnnotationBo> annotationBoList = event.getAnnotationBoList();
            if (annotationBoList == null) {
                continue;
            }
            for (AnnotationBo annotationBo : annotationBoList) {
                //                    TODO ?? url format & annotation type detect
                int key = annotationBo.getKey();
                if (isURL(key)) {
                    String url = (String) annotationBo.getValue();
                    String path = getPath(url);
                    final boolean match = matcher.match(urlPattern, path);
                    if (match) {
                        return ACCEPT;
                    }
                }
            }
        }
    }
    return REJECT;
}
Also used : AnnotationBo(com.navercorp.pinpoint.common.server.bo.AnnotationBo) ServiceType(com.navercorp.pinpoint.common.trace.ServiceType) SpanBo(com.navercorp.pinpoint.common.server.bo.SpanBo) SpanEventBo(com.navercorp.pinpoint.common.server.bo.SpanEventBo)

Aggregations

SpanEventBo (com.navercorp.pinpoint.common.server.bo.SpanEventBo)60 Test (org.junit.Test)28 SpanBo (com.navercorp.pinpoint.common.server.bo.SpanBo)14 Buffer (com.navercorp.pinpoint.common.buffer.Buffer)9 AnnotationBo (com.navercorp.pinpoint.common.server.bo.AnnotationBo)9 ByteBuffer (java.nio.ByteBuffer)8 OffsetFixedBuffer (com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer)5 SpanChunkBo (com.navercorp.pinpoint.common.server.bo.SpanChunkBo)5 TransactionId (com.navercorp.pinpoint.common.util.TransactionId)5 AutomaticBuffer (com.navercorp.pinpoint.common.buffer.AutomaticBuffer)4 ServiceType (com.navercorp.pinpoint.common.trace.ServiceType)4 ArrayList (java.util.ArrayList)4 BasePinpointTest (com.navercorp.pinpoint.test.junit4.BasePinpointTest)3 BasicSpan (com.navercorp.pinpoint.common.server.bo.BasicSpan)2 SpanBitFiled (com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.bitfield.SpanBitFiled)2 Put (org.apache.hadoop.hbase.client.Put)2 ApiMetaDataBo (com.navercorp.pinpoint.common.server.bo.ApiMetaDataBo)1 SpanDecodingContext (com.navercorp.pinpoint.common.server.bo.serializer.trace.v1.SpanDecodingContext)1 SpanDecodingContext (com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.SpanDecodingContext)1 SpanEncoder (com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.SpanEncoder)1