Search in sources :

Example 46 with SpanBo

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

the class SpanIdMatcherTest method testApproximateMatchEqualsCase.

@Test
public void testApproximateMatchEqualsCase() throws Exception {
    List<SpanBo> matchSpanList = new ArrayList<SpanBo>();
    SpanBo spanBo1 = new SpanBo();
    spanBo1.setStartTime(2);
    matchSpanList.add(spanBo1);
    SpanBo spanBo2 = new SpanBo();
    spanBo2.setStartTime(2);
    matchSpanList.add(spanBo2);
    SpanIdMatcher spanIdMatcher = new SpanIdMatcher(matchSpanList);
    SpanBo match = spanIdMatcher.approximateMatch(1);
    Assert.assertTrue(match == spanBo1);
    Assert.assertEquals(1, spanIdMatcher.other().size());
    Assert.assertTrue(spanBo2 == spanIdMatcher.other().get(0));
}
Also used : ArrayList(java.util.ArrayList) SpanBo(com.navercorp.pinpoint.common.server.bo.SpanBo) Test(org.junit.Test)

Example 47 with SpanBo

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

the class SpanHandler method handleSimple.

public void handleSimple(TBase<?, ?> tbase) {
    if (!(tbase instanceof TSpan)) {
        throw new IllegalArgumentException("unexpected tbase:" + tbase + " expected:" + this.getClass().getName());
    }
    try {
        final TSpan tSpan = (TSpan) tbase;
        if (logger.isDebugEnabled()) {
            logger.debug("Received SPAN={}", tSpan);
        }
        final SpanBo spanBo = spanFactory.buildSpanBo(tSpan);
        traceDao.insert(spanBo);
        applicationTraceIndexDao.insert(tSpan);
        // insert statistics info for server map
        insertAcceptorHost(spanBo);
        insertSpanStat(spanBo);
        insertSpanEventStat(spanBo);
    } catch (Exception e) {
        logger.warn("Span handle error. Caused:{}. Span:{}", e.getMessage(), tbase, e);
    }
}
Also used : TSpan(com.navercorp.pinpoint.thrift.dto.TSpan) SpanBo(com.navercorp.pinpoint.common.server.bo.SpanBo)

Example 48 with SpanBo

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

the class SpanDecoderV0 method readSpan.

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

Example 49 with SpanBo

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

the class SpanEncoderV0 method encodeSpanQualifier.

@Override
public ByteBuffer encodeSpanQualifier(SpanEncodingContext<SpanBo> encodingContext) {
    final SpanBo spanBo = encodingContext.getValue();
    final List<SpanEventBo> spanEventBoList = spanBo.getSpanEventBoList();
    final SpanEventBo firstEvent = getFirstSpanEvent(spanEventBoList);
    return encodeQualifier(TYPE_SPAN, spanBo.getApplicationId(), spanBo.getAgentId(), spanBo.getAgentStartTime(), spanBo.getSpanId(), firstEvent);
}
Also used : SpanBo(com.navercorp.pinpoint.common.server.bo.SpanBo) SpanEventBo(com.navercorp.pinpoint.common.server.bo.SpanEventBo)

Example 50 with SpanBo

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

the class SpanEncoderV0 method encodeSpanColumnValue.

@Override
public ByteBuffer encodeSpanColumnValue(SpanEncodingContext<SpanBo> encodingContext) {
    final SpanBo span = encodingContext.getValue();
    final SpanBitFiled bitField = SpanBitFiled.build(span);
    final Buffer buffer = new AutomaticBuffer(256);
    final byte version = span.getRawVersion();
    buffer.putByte(version);
    // bit field
    buffer.putByte(bitField.getBitField());
    final short serviceType = span.getServiceType();
    buffer.putShort(serviceType);
    switch(bitField.getApplicationServiceTypeEncodingStrategy()) {
        case PREV_EQUALS:
            break;
        case RAW:
            buffer.putShort(span.getApplicationServiceType());
            break;
        default:
            throw new IllegalStateException("applicationServiceType");
    }
    // buffer.put(spanID);
    if (!bitField.isRoot()) {
        buffer.putLong(span.getParentSpanId());
    }
    // prevSpanEvent coding
    final long startTime = span.getStartTime();
    final long startTimeDelta = span.getCollectorAcceptTime() - startTime;
    buffer.putVLong(startTimeDelta);
    buffer.putVInt(span.getElapsed());
    buffer.putPrefixedString(span.getRpc());
    buffer.putPrefixedString(span.getEndPoint());
    buffer.putPrefixedString(span.getRemoteAddr());
    buffer.putSVInt(span.getApiId());
    // BIT flag
    if (bitField.isSetErrorCode()) {
        buffer.putInt(span.getErrCode());
    }
    if (bitField.isSetHasException()) {
        buffer.putSVInt(span.getExceptionId());
        buffer.putPrefixedString(span.getExceptionMessage());
    }
    if (bitField.isSetFlag()) {
        buffer.putShort(span.getFlag());
    }
    if (bitField.isSetLoggingTransactionInfo()) {
        buffer.putByte(span.getLoggingTransactionInfo());
    }
    buffer.putPrefixedString(span.getAcceptorHost());
    if (bitField.isSetAnnotation()) {
        List<AnnotationBo> annotationBoList = span.getAnnotationBoList();
        writeAnnotationList(buffer, annotationBoList, encodingContext);
    }
    final List<SpanEventBo> spanEventBoList = span.getSpanEventBoList();
    writeSpanEventList(buffer, spanEventBoList, encodingContext);
    return buffer.wrapByteBuffer();
}
Also used : Buffer(com.navercorp.pinpoint.common.buffer.Buffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) ByteBuffer(java.nio.ByteBuffer) AnnotationBo(com.navercorp.pinpoint.common.server.bo.AnnotationBo) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) SpanBitFiled(com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.bitfield.SpanBitFiled) SpanBo(com.navercorp.pinpoint.common.server.bo.SpanBo) SpanEventBo(com.navercorp.pinpoint.common.server.bo.SpanEventBo)

Aggregations

SpanBo (com.navercorp.pinpoint.common.server.bo.SpanBo)65 Test (org.junit.Test)32 SpanEventBo (com.navercorp.pinpoint.common.server.bo.SpanEventBo)14 ArrayList (java.util.ArrayList)10 Buffer (com.navercorp.pinpoint.common.buffer.Buffer)8 TransactionId (com.navercorp.pinpoint.common.util.TransactionId)8 OffsetFixedBuffer (com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer)7 ByteBuffer (java.nio.ByteBuffer)7 AnnotationBo (com.navercorp.pinpoint.common.server.bo.AnnotationBo)5 ServiceType (com.navercorp.pinpoint.common.trace.ServiceType)4 BasePinpointTest (com.navercorp.pinpoint.test.junit4.BasePinpointTest)4 IsRootSpan (com.navercorp.pinpoint.test.junit4.IsRootSpan)4 List (java.util.List)4 SpanChunkBo (com.navercorp.pinpoint.common.server.bo.SpanChunkBo)2 SpanDecodingContext (com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.SpanDecodingContext)2 Application (com.navercorp.pinpoint.web.vo.Application)2 Dot (com.navercorp.pinpoint.web.vo.scatter.Dot)2 Cell (org.apache.hadoop.hbase.Cell)2 AutomaticBuffer (com.navercorp.pinpoint.common.buffer.AutomaticBuffer)1 SpanDecodingContext (com.navercorp.pinpoint.common.server.bo.serializer.trace.v1.SpanDecodingContext)1