Search in sources :

Example 51 with SpanBo

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

the class SpanBoTest method testVersion.

@Test
public void testVersion() {
    SpanBo spanBo = new SpanBo();
    checkVersion(spanBo, 0);
    checkVersion(spanBo, 254);
    checkVersion(spanBo, 255);
    try {
        checkVersion(spanBo, 256);
        Assert.fail();
    } catch (Exception ignored) {
    }
    byte byteVersion = 2;
    spanBo.setVersion(byteVersion);
    Assert.assertTrue(spanBo.getRawVersion() == byteVersion);
}
Also used : SpanBo(com.navercorp.pinpoint.common.server.bo.SpanBo) Test(org.junit.Test)

Example 52 with SpanBo

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

the class SpanEventBoTest method testSerialize.

@Test
public void testSerialize() throws Exception {
    SpanBo spanBo = new SpanBo();
    spanBo.setAgentId("testAgent");
    spanBo.setApplicationId("testApp");
    spanBo.setAgentStartTime(1);
    spanBo.setSpanId(12);
    SpanEventBo spanEventBo = new SpanEventBo();
    spanEventBo.setDepth(3);
    spanEventBo.setDestinationId("testdest");
    spanEventBo.setEndElapsed(2);
    spanEventBo.setEndPoint("endpoint");
    spanEventBo.setNextSpanId(4);
    spanEventBo.setRpc("rpc");
    spanEventBo.setServiceType(ServiceType.STAND_ALONE.getCode());
    spanEventBo.setStartElapsed(100);
    spanEventBo.setNextAsyncId(1000);
    SpanEventEncodingContext spanEventEncodingContext = new SpanEventEncodingContext(spanBo, spanEventBo);
    ByteBuffer bytes = serializer.writeValue(spanEventEncodingContext);
    SpanEventBo newSpanEventBo = new SpanEventBo();
    SpanDecodingContext spanDecodingContext = new SpanDecodingContext();
    Buffer buffer = new OffsetFixedBuffer(bytes.array(), bytes.arrayOffset(), bytes.remaining());
    int i = spanDecoder.readSpanEvent(newSpanEventBo, buffer, spanDecodingContext);
    Assert.assertEquals(bytes.limit(), i);
    Assert.assertEquals(spanBo.getAgentId(), spanDecodingContext.getAgentId());
    Assert.assertEquals(spanBo.getApplicationId(), spanDecodingContext.getApplicationId());
    Assert.assertEquals(spanBo.getAgentStartTime(), spanDecodingContext.getAgentStartTime());
    Assert.assertEquals(spanEventBo.getDepth(), newSpanEventBo.getDepth());
    Assert.assertEquals(spanEventBo.getDestinationId(), newSpanEventBo.getDestinationId());
    Assert.assertEquals(spanEventBo.getEndElapsed(), newSpanEventBo.getEndElapsed());
    Assert.assertEquals(spanEventBo.getEndPoint(), newSpanEventBo.getEndPoint());
    Assert.assertEquals(spanEventBo.getNextSpanId(), newSpanEventBo.getNextSpanId());
    Assert.assertEquals(spanEventBo.getRpc(), newSpanEventBo.getRpc());
    Assert.assertEquals(spanEventBo.getServiceType(), newSpanEventBo.getServiceType());
    Assert.assertEquals(spanEventBo.getStartElapsed(), newSpanEventBo.getStartElapsed());
    Assert.assertEquals(spanEventBo.getNextAsyncId(), newSpanEventBo.getNextAsyncId());
    spanEventBo.setSequence((short) 3);
    newSpanEventBo.setSequence((short) 3);
    Assert.assertEquals(spanEventBo.getSequence(), newSpanEventBo.getSequence());
}
Also used : Buffer(com.navercorp.pinpoint.common.buffer.Buffer) OffsetFixedBuffer(com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer) ByteBuffer(java.nio.ByteBuffer) OffsetFixedBuffer(com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer) SpanBo(com.navercorp.pinpoint.common.server.bo.SpanBo) ByteBuffer(java.nio.ByteBuffer) SpanEventBo(com.navercorp.pinpoint.common.server.bo.SpanEventBo) Test(org.junit.Test)

Example 53 with SpanBo

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

the class SpanEncoderTest method testEncodeSpanColumnValue_spanEvent_depth_equals.

@Test
public void testEncodeSpanColumnValue_spanEvent_depth_equals() {
    SpanBo spanBo = randomComplexSpan();
    SpanEventBo spanEventBo0 = spanBo.getSpanEventBoList().get(0);
    SpanEventBo spanEventBo1 = spanBo.getSpanEventBoList().get(1);
    spanEventBo1.setDepth(spanEventBo0.getDepth());
    assertSpan(spanBo);
}
Also used : SpanBo(com.navercorp.pinpoint.common.server.bo.SpanBo) SpanEventBo(com.navercorp.pinpoint.common.server.bo.SpanEventBo) Test(org.junit.Test)

Example 54 with SpanBo

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

the class SpanEncoderTest method testEncodeSpanColumnValue_simpleSpan.

@Test
public void testEncodeSpanColumnValue_simpleSpan() throws Exception {
    SpanBo spanBo = randomSpan();
    assertSpan(spanBo);
}
Also used : SpanBo(com.navercorp.pinpoint.common.server.bo.SpanBo) Test(org.junit.Test)

Example 55 with SpanBo

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

the class SpanEncoderTest method assertSpan.

private void assertSpan(SpanBo spanBo) {
    spanBo.setCollectorAcceptTime(getCollectorAcceptTime());
    SpanEncodingContext<SpanBo> encodingContext = new SpanEncodingContext<SpanBo>(spanBo);
    Buffer qualifier = wrapBuffer(spanEncoder.encodeSpanQualifier(encodingContext));
    Buffer column = wrapBuffer(spanEncoder.encodeSpanColumnValue(encodingContext));
    SpanDecodingContext decodingContext = new SpanDecodingContext();
    decodingContext.setTransactionId(spanBo.getTransactionId());
    decodingContext.setCollectorAcceptedTime(spanBo.getCollectorAcceptTime());
    SpanBo decode = (SpanBo) spanDecoder.decode(qualifier, column, decodingContext);
    logger.debug("span dump \noriginal spanBo:{} \ndecode spanBo:{} ", spanBo, decode);
    List<String> notSerializedField = Lists.newArrayList("parentApplicationId", "parentApplicationServiceType");
    List<String> excludeField = Lists.newArrayList("annotationBoList", "spanEventBoList");
    notSerializedField.addAll(excludeField);
    Assert.assertTrue(EqualsBuilder.reflectionEquals(decode, spanBo, notSerializedField));
    logger.debug("{} {}", spanBo.getAnnotationBoList(), decode.getAnnotationBoList());
    Assert.assertTrue("annotation", EqualsBuilder.reflectionEquals(spanBo.getAnnotationBoList(), decode.getAnnotationBoList()));
    List<SpanEventBo> spanEventBoList = spanBo.getSpanEventBoList();
    List<SpanEventBo> decodedSpanEventBoList = decode.getSpanEventBoList();
    Assert.assertTrue(EqualsBuilder.reflectionEquals(spanEventBoList, decodedSpanEventBoList));
}
Also used : Buffer(com.navercorp.pinpoint.common.buffer.Buffer) OffsetFixedBuffer(com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer) ByteBuffer(java.nio.ByteBuffer) 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