Search in sources :

Example 6 with SpanChunkBo

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

the class SpanMapperV2 method bindSpanChunk.

private List<SpanBo> bindSpanChunk(ListMultimap<AgentKey, SpanBo> spanMap, List<SpanChunkBo> spanChunkList) {
    for (SpanChunkBo spanChunkBo : spanChunkList) {
        AgentKey agentKey = newAgentKey(spanChunkBo);
        List<SpanBo> matchedSpanBoList = spanMap.get(agentKey);
        if (matchedSpanBoList != null) {
            final int spanIdCollisionSize = matchedSpanBoList.size();
            if (spanIdCollisionSize > 1) {
                // exceptional case dump
                logger.warn("spanIdCollision {}", matchedSpanBoList);
            }
            int agentLevelCollisionCount = 0;
            for (SpanBo spanBo : matchedSpanBoList) {
                if (StringUtils.equals(spanBo.getAgentId(), spanChunkBo.getAgentId())) {
                    spanBo.addSpanEventBoList(spanChunkBo.getSpanEventBoList());
                    agentLevelCollisionCount++;
                }
            }
            if (agentLevelCollisionCount > 1) {
                // exceptional case dump
                logger.warn("agentLevelCollision {}", matchedSpanBoList);
            }
        } else {
            if (logger.isInfoEnabled()) {
                logger.info("Span not exist spanId:{} spanChunk:{}", agentKey, spanChunkBo);
            }
        }
    }
    return Lists.newArrayList(spanMap.values());
}
Also used : SpanChunkBo(com.navercorp.pinpoint.common.server.bo.SpanChunkBo) SpanBo(com.navercorp.pinpoint.common.server.bo.SpanBo)

Example 7 with SpanChunkBo

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

the class SpanMapperV2 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();
    ListMultimap<AgentKey, SpanBo> spanMap = LinkedListMultimap.create();
    List<SpanChunkBo> spanChunkList = new ArrayList<>();
    final SpanDecodingContext decodingContext = new SpanDecodingContext();
    decodingContext.setTransactionId(transactionId);
    for (Cell cell : rawCells) {
        SpanDecoder spanDecoder = null;
        // only if family name is "span"
        if (CellUtil.matchingFamily(cell, HBaseTables.TRACE_V2_CF_SPAN)) {
            decodingContext.setCollectorAcceptedTime(cell.getTimestamp());
            final Buffer qualifier = new OffsetFixedBuffer(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength());
            final Buffer columnValue = new OffsetFixedBuffer(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
            spanDecoder = resolveDecoder(columnValue);
            final Object decodeObject = spanDecoder.decode(qualifier, columnValue, decodingContext);
            if (decodeObject instanceof SpanBo) {
                SpanBo spanBo = (SpanBo) decodeObject;
                if (logger.isDebugEnabled()) {
                    logger.debug("spanBo:{}", spanBo);
                }
                AgentKey agentKey = newAgentKey(spanBo);
                spanMap.put(agentKey, spanBo);
            } else if (decodeObject instanceof SpanChunkBo) {
                SpanChunkBo spanChunkBo = (SpanChunkBo) decodeObject;
                if (logger.isDebugEnabled()) {
                    logger.debug("spanChunkBo:{}", spanChunkBo);
                }
                spanChunkList.add(spanChunkBo);
            }
        } else {
            logger.warn("Unknown ColumnFamily :{}", Bytes.toStringBinary(CellUtil.cloneFamily(cell)));
        }
        nextCell(spanDecoder, decodingContext);
    }
    decodingContext.finish();
    return buildSpanBoList(spanMap, spanChunkList);
}
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.v2.SpanDecodingContext) SpanChunkBo(com.navercorp.pinpoint.common.server.bo.SpanChunkBo) SpanDecoder(com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.SpanDecoder) ArrayList(java.util.ArrayList) OffsetFixedBuffer(com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer) SpanBo(com.navercorp.pinpoint.common.server.bo.SpanBo) TransactionId(com.navercorp.pinpoint.common.util.TransactionId) Cell(org.apache.hadoop.hbase.Cell)

Example 8 with SpanChunkBo

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

the class SpanChunkHandler method handleSimple.

@Override
public void handleSimple(TBase<?, ?> tbase) {
    try {
        final SpanChunkBo spanChunkBo = newSpanChunkBo(tbase);
        traceDao.insertSpanChunk(spanChunkBo);
        final ServiceType applicationServiceType = getApplicationServiceType(spanChunkBo);
        List<SpanEventBo> spanEventList = spanChunkBo.getSpanEventBoList();
        if (spanEventList != null) {
            if (logger.isDebugEnabled()) {
                logger.debug("SpanChunk Size:{}", spanEventList.size());
            }
            // TODO need to batch update later.
            for (SpanEventBo spanEvent : spanEventList) {
                final ServiceType spanEventType = registry.findServiceType(spanEvent.getServiceType());
                if (!spanEventType.isRecordStatistics()) {
                    continue;
                }
                // if terminal update statistics
                final int elapsed = spanEvent.getEndElapsed();
                final boolean hasException = spanEvent.hasException();
                /*
                     * save information to draw a server map based on statistics
                     */
                // save the information of caller (the spanevent that span called)
                statisticsHandler.updateCaller(spanChunkBo.getApplicationId(), applicationServiceType, spanChunkBo.getAgentId(), spanEvent.getDestinationId(), spanEventType, spanEvent.getEndPoint(), elapsed, hasException);
                // save the information of callee (the span that called spanevent)
                statisticsHandler.updateCallee(spanEvent.getDestinationId(), spanEventType, spanChunkBo.getApplicationId(), applicationServiceType, spanChunkBo.getEndPoint(), elapsed, hasException);
            }
        }
    } catch (Exception e) {
        logger.warn("SpanChunk handle error Caused:{}", e.getMessage(), e);
    }
}
Also used : SpanChunkBo(com.navercorp.pinpoint.common.server.bo.SpanChunkBo) ServiceType(com.navercorp.pinpoint.common.trace.ServiceType) SpanEventBo(com.navercorp.pinpoint.common.server.bo.SpanEventBo)

Example 9 with SpanChunkBo

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

the class SpanDecoderV0 method readSpanChunk.

private SpanChunkBo readSpanChunk(Buffer qualifier, Buffer columnValue, SpanDecodingContext decodingContext) {
    final SpanChunkBo spanChunk = new SpanChunkBo();
    final TransactionId transactionId = decodingContext.getTransactionId();
    spanChunk.setTransactionId(transactionId);
    spanChunk.setCollectorAcceptTime(decodingContext.getCollectorAcceptedTime());
    SpanEventBo firstSpanEvent = readQualifier(spanChunk, qualifier);
    readSpanChunkValue(columnValue, spanChunk, firstSpanEvent, decodingContext);
    return spanChunk;
}
Also used : SpanChunkBo(com.navercorp.pinpoint.common.server.bo.SpanChunkBo) SpanEventBo(com.navercorp.pinpoint.common.server.bo.SpanEventBo) TransactionId(com.navercorp.pinpoint.common.util.TransactionId)

Example 10 with SpanChunkBo

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

the class SpanEncoderTest method testEncodeSpanColumnValue_complexSpanChunk.

@Test
public void testEncodeSpanColumnValue_complexSpanChunk() throws Exception {
    SpanChunkBo spanChunkBo = randomComplexSpanChunk();
    assertSpanChunk(spanChunkBo);
}
Also used : SpanChunkBo(com.navercorp.pinpoint.common.server.bo.SpanChunkBo) Test(org.junit.Test)

Aggregations

SpanChunkBo (com.navercorp.pinpoint.common.server.bo.SpanChunkBo)10 SpanEventBo (com.navercorp.pinpoint.common.server.bo.SpanEventBo)5 Buffer (com.navercorp.pinpoint.common.buffer.Buffer)3 ByteBuffer (java.nio.ByteBuffer)3 OffsetFixedBuffer (com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer)2 SpanBo (com.navercorp.pinpoint.common.server.bo.SpanBo)2 TransactionId (com.navercorp.pinpoint.common.util.TransactionId)2 Test (org.junit.Test)2 AutomaticBuffer (com.navercorp.pinpoint.common.buffer.AutomaticBuffer)1 SpanDecoder (com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.SpanDecoder)1 SpanDecodingContext (com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.SpanDecodingContext)1 ServiceType (com.navercorp.pinpoint.common.trace.ServiceType)1 ArrayList (java.util.ArrayList)1 Cell (org.apache.hadoop.hbase.Cell)1