Search in sources :

Example 11 with SpanChunkBo

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

the class SpanChunkSerializerV2 method serialize.

@Override
public void serialize(SpanChunkBo spanChunkBo, Put put, SerializationContext context) {
    Objects.requireNonNull(spanChunkBo, "spanChunkBo");
    SpanEncodingContext<SpanChunkBo> encodingContext = new SpanEncodingContext<>(spanChunkBo);
    ByteBuffer qualifier = spanEncoder.encodeSpanChunkQualifier(encodingContext);
    ByteBuffer columnValue = spanEncoder.encodeSpanChunkColumnValue(encodingContext);
    long acceptedTime = put.getTimeStamp();
    put.addColumn(HbaseColumnFamily.TRACE_V2_SPAN.getName(), qualifier, acceptedTime, columnValue);
}
Also used : SpanChunkBo(com.navercorp.pinpoint.common.server.bo.SpanChunkBo) ByteBuffer(java.nio.ByteBuffer)

Example 12 with SpanChunkBo

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

the class CollectorGrpcSpanFactory method buildSpanChunkBo.

@Override
public SpanChunkBo buildSpanChunkBo(PSpanChunk pSpanChunk, Header header) {
    final SpanChunkBo spanChunkBo = this.grpcBinder.bindSpanChunkBo(pSpanChunk, header);
    final long acceptedTime = acceptedTimeService.getAcceptedTime();
    spanChunkBo.setCollectorAcceptTime(acceptedTime);
    final List<PSpanEvent> pSpanEventList = pSpanChunk.getSpanEventList();
    List<SpanEventBo> spanEventList = buildSpanEventBoList(pSpanEventList);
    spanChunkBo.addSpanEventBoList(spanEventList);
    return spanChunkBo;
}
Also used : SpanChunkBo(com.navercorp.pinpoint.common.server.bo.SpanChunkBo) PSpanEvent(com.navercorp.pinpoint.grpc.trace.PSpanEvent) SpanEventBo(com.navercorp.pinpoint.common.server.bo.SpanEventBo)

Example 13 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 (CollectionUtils.hasLength(matchedSpanBoList)) {
            final int spanIdCollisionSize = matchedSpanBoList.size();
            if (spanIdCollisionSize > 1) {
                // exceptional case dump
                logger.warn("spanIdCollision {}", matchedSpanBoList);
            }
            int agentLevelCollisionCount = 0;
            for (SpanBo spanBo : matchedSpanBoList) {
                if (isChildSpanChunk(spanBo, spanChunkBo)) {
                    spanBo.addSpanChunkBo(spanChunkBo);
                    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 new ArrayList<>(spanMap.values());
}
Also used : SpanChunkBo(com.navercorp.pinpoint.common.server.bo.SpanChunkBo) ArrayList(java.util.ArrayList) SpanBo(com.navercorp.pinpoint.common.server.bo.SpanBo)

Example 14 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);
    final BufferFactory bufferFactory = new BufferFactory(cacheSize);
    for (Cell cell : rawCells) {
        SpanDecoder spanDecoder = null;
        // only if family name is "span"
        if (CellUtil.matchingFamily(cell, HbaseColumnFamily.TRACE_V2_SPAN.getName())) {
            decodingContext.setCollectorAcceptedTime(cell.getTimestamp());
            final Buffer qualifier = bufferFactory.createBuffer(CellUtil.cloneQualifier(cell));
            final Buffer columnValue = bufferFactory.createBuffer(CellUtil.cloneValue(cell));
            spanDecoder = resolveDecoder(columnValue);
            final Object decodeObject = spanDecoder.decode(qualifier, columnValue, decodingContext);
            if (decodeObject instanceof SpanBo) {
                SpanBo spanBo = (SpanBo) decodeObject;
                if (logger.isTraceEnabled()) {
                    logger.trace("spanBo:{}", spanBo);
                }
                AgentKey agentKey = newAgentKey(spanBo);
                spanMap.put(agentKey, spanBo);
            } else if (decodeObject instanceof SpanChunkBo) {
                SpanChunkBo spanChunkBo = (SpanChunkBo) decodeObject;
                if (logger.isTraceEnabled()) {
                    logger.trace("spanChunkBo:{}", spanChunkBo);
                }
                spanChunkList.add(spanChunkBo);
            }
        } else {
            if (logger.isWarnEnabled()) {
                String columnFamily = Bytes.toStringBinary(cell.getFamilyArray(), cell.getFamilyOffset(), cell.getFamilyLength());
                logger.warn("Unknown ColumnFamily :{}", columnFamily);
            }
        }
        nextCell(spanDecoder, decodingContext);
    }
    decodingContext.finish();
    return buildSpanBoList(spanMap, spanChunkList);
}
Also used : FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) ByteBuffer(java.nio.ByteBuffer) StringCacheableBuffer(com.navercorp.pinpoint.common.buffer.StringCacheableBuffer) Buffer(com.navercorp.pinpoint.common.buffer.Buffer) 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) SpanBo(com.navercorp.pinpoint.common.server.bo.SpanBo) TransactionId(com.navercorp.pinpoint.common.profiler.util.TransactionId) Cell(org.apache.hadoop.hbase.Cell)

Example 15 with SpanChunkBo

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

the class SpanReader method accept.

public boolean accept(SpanVisitor spanVisitor) {
    Objects.requireNonNull(spanVisitor, "spanVisitor");
    if (CollectionUtils.isEmpty(spanBoList)) {
        return SpanVisitor.REJECT;
    }
    for (SpanBo spanBo : spanBoList) {
        if (spanVisitor.visit(spanBo)) {
            return SpanVisitor.ACCEPT;
        }
        final List<SpanEventBo> spanEventBoList = spanBo.getSpanEventBoList();
        if (visitSpanEventList(spanVisitor, spanEventBoList)) {
            return SpanVisitor.ACCEPT;
        }
        List<SpanChunkBo> spanChunkBoList = spanBo.getSpanChunkBoList();
        if (CollectionUtils.hasLength(spanChunkBoList)) {
            for (SpanChunkBo spanChunkBo : spanChunkBoList) {
                if (spanVisitor.visit(spanChunkBo)) {
                    return SpanVisitor.ACCEPT;
                }
                List<SpanEventBo> spanChunkEventBoList = spanChunkBo.getSpanEventBoList();
                if (visitSpanEventList(spanVisitor, spanChunkEventBoList)) {
                    return SpanVisitor.ACCEPT;
                }
            }
        }
    }
    return SpanVisitor.REJECT;
}
Also used : SpanChunkBo(com.navercorp.pinpoint.common.server.bo.SpanChunkBo) SpanBo(com.navercorp.pinpoint.common.server.bo.SpanBo) SpanEventBo(com.navercorp.pinpoint.common.server.bo.SpanEventBo)

Aggregations

SpanChunkBo (com.navercorp.pinpoint.common.server.bo.SpanChunkBo)27 SpanEventBo (com.navercorp.pinpoint.common.server.bo.SpanEventBo)13 Test (org.junit.Test)8 Header (com.navercorp.pinpoint.grpc.Header)5 TransactionId (com.navercorp.pinpoint.common.profiler.util.TransactionId)4 LocalAsyncIdBo (com.navercorp.pinpoint.common.server.bo.LocalAsyncIdBo)4 PSpanChunk (com.navercorp.pinpoint.grpc.trace.PSpanChunk)4 ByteBuffer (java.nio.ByteBuffer)4 Buffer (com.navercorp.pinpoint.common.buffer.Buffer)3 SpanBo (com.navercorp.pinpoint.common.server.bo.SpanBo)3 ArrayList (java.util.ArrayList)3 FixedBuffer (com.navercorp.pinpoint.common.buffer.FixedBuffer)2 TSpanChunk (com.navercorp.pinpoint.thrift.dto.TSpanChunk)2 TSpanEvent (com.navercorp.pinpoint.thrift.dto.TSpanEvent)2 AutomaticBuffer (com.navercorp.pinpoint.common.buffer.AutomaticBuffer)1 StringCacheableBuffer (com.navercorp.pinpoint.common.buffer.StringCacheableBuffer)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 PLocalAsyncId (com.navercorp.pinpoint.grpc.trace.PLocalAsyncId)1