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);
}
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());
}
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);
}
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);
}
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));
}
Aggregations