Search in sources :

Example 46 with SpanEventBo

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

the class SpanEventBitFieldTest method testSequence_add1_next.

@Test
public void testSequence_add1_next() throws Exception {
    SpanEventBo prev = new SpanEventBo();
    SpanEventBo current = new SpanEventBo();
    prev.setSequence((short) 10);
    current.setSequence((short) 11);
    SpanEventBitField bitField = SpanEventBitField.build(current, prev);
    Assert.assertEquals(bitField.getSequenceEncodingStrategy(), SequenceEncodingStrategy.PREV_ADD1);
}
Also used : SpanEventBo(com.navercorp.pinpoint.common.server.bo.SpanEventBo) Test(org.junit.Test)

Example 47 with SpanEventBo

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

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

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

Example 50 with SpanEventBo

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

the class SpanEventBitFieldTest method testRpc_first.

@Test
public void testRpc_first() throws Exception {
    SpanEventBo spanEventBo = new SpanEventBo();
    spanEventBo.setRpc("Rpc");
    SpanEventBitField bitField = SpanEventBitField.buildFirst(spanEventBo);
    Assert.assertTrue(bitField.isSetRpc());
    bitField.setRpc(false);
    Assert.assertFalse(bitField.isSetRpc());
}
Also used : SpanEventBo(com.navercorp.pinpoint.common.server.bo.SpanEventBo) Test(org.junit.Test)

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