use of com.navercorp.pinpoint.common.buffer.Buffer in project pinpoint by naver.
the class AnnotationBoDecoderTest method testWriteValue.
@Test
public void testWriteValue() throws Exception {
final AnnotationBo annotation = new AnnotationBo();
annotation.setKey(AnnotationKey.API.getCode());
final String value = RandomStringUtils.random(RandomUtils.nextInt(0, 20));
annotation.setValue(value);
final Buffer buffer = new AutomaticBuffer(128);
this.serializer.writeAnnotationList(Lists.newArrayList(annotation), buffer);
buffer.setOffset(0);
List<AnnotationBo> decode = annotationBoDecoder.decode(buffer);
Assert.assertEquals(decode.size(), 1);
AnnotationBo decodedAnnotation = decode.get(0);
Assert.assertEquals(annotation.getKey(), decodedAnnotation.getKey());
Assert.assertEquals(annotation.getValue(), decodedAnnotation.getValue());
}
use of com.navercorp.pinpoint.common.buffer.Buffer in project pinpoint by naver.
the class SpanBoTest method serialize_V1.
@Test
public void serialize_V1() {
final SpanBo spanBo = new SpanBo();
spanBo.setAgentId("agentId");
spanBo.setApplicationId("applicationId");
spanBo.setEndPoint("end");
spanBo.setRpc("rpc");
spanBo.setParentSpanId(5);
spanBo.setAgentStartTime(1);
TransactionId transactionId = new TransactionId("agentId", 2, 3);
spanBo.setTransactionId(transactionId);
spanBo.setElapsed(4);
spanBo.setStartTime(5);
spanBo.setServiceType(ServiceType.STAND_ALONE.getCode());
spanBo.setLoggingTransactionInfo(LoggingInfo.INFO.getCode());
spanBo.setExceptionInfo(1000, "Exception");
ByteBuffer bytes = spanSerializer.writeColumnValue(spanBo);
SpanBo newSpanBo = new SpanBo();
Buffer valueBuffer = new OffsetFixedBuffer(bytes.array(), bytes.arrayOffset(), bytes.remaining());
int i = spanDecoder.readSpan(newSpanBo, valueBuffer);
logger.debug("length:{}", i);
Assert.assertEquals(bytes.limit(), i);
Assert.assertEquals(newSpanBo.getAgentId(), spanBo.getAgentId());
Assert.assertEquals(newSpanBo.getApplicationId(), spanBo.getApplicationId());
Assert.assertEquals(newSpanBo.getAgentStartTime(), spanBo.getAgentStartTime());
Assert.assertEquals(newSpanBo.getElapsed(), spanBo.getElapsed());
Assert.assertEquals(newSpanBo.getEndPoint(), spanBo.getEndPoint());
Assert.assertEquals(newSpanBo.getErrCode(), spanBo.getErrCode());
Assert.assertEquals(newSpanBo.getFlag(), spanBo.getFlag());
// not included for serialization
// Assert.assertEquals(newSpanBo.getTraceAgentStartTime(), spanBo.getTraceAgentStartTime());
// Assert.assertEquals(newSpanBo.getTraceTransactionSequence(), spanBo.getTraceTransactionSequence());
Assert.assertEquals(newSpanBo.getParentSpanId(), spanBo.getParentSpanId());
Assert.assertEquals(newSpanBo.getServiceType(), spanBo.getServiceType());
Assert.assertEquals(newSpanBo.getApplicationServiceType(), spanBo.getServiceType());
Assert.assertEquals(newSpanBo.getVersion(), spanBo.getVersion());
Assert.assertEquals(newSpanBo.getLoggingTransactionInfo(), spanBo.getLoggingTransactionInfo());
Assert.assertEquals(newSpanBo.getExceptionId(), spanBo.getExceptionId());
Assert.assertEquals(newSpanBo.getExceptionMessage(), spanBo.getExceptionMessage());
}
use of com.navercorp.pinpoint.common.buffer.Buffer in project pinpoint by naver.
the class SpanBoTest method serialize2_V1.
@Test
public void serialize2_V1() {
SpanBo spanBo = new SpanBo();
spanBo.setAgentId("agent");
String service = createString(5);
spanBo.setApplicationId(service);
String endPoint = createString(127);
spanBo.setEndPoint(endPoint);
String rpc = createString(255);
spanBo.setRpc(rpc);
spanBo.setServiceType(ServiceType.STAND_ALONE.getCode());
spanBo.setApplicationServiceType(ServiceType.UNKNOWN.getCode());
final ByteBuffer bytes = spanSerializer.writeColumnValue(spanBo);
SpanBo newSpanBo = new SpanBo();
Buffer valueBuffer = new OffsetFixedBuffer(bytes.array(), bytes.arrayOffset(), bytes.remaining());
int i = spanDecoder.readSpan(newSpanBo, valueBuffer);
logger.debug("length:{}", i);
Assert.assertEquals(bytes.limit(), i);
Assert.assertEquals(spanBo.getServiceType(), spanBo.getServiceType());
Assert.assertEquals(spanBo.getApplicationServiceType(), spanBo.getApplicationServiceType());
}
use of com.navercorp.pinpoint.common.buffer.Buffer in project pinpoint by naver.
the class TransactionIdUtils method parseTransactionId.
public static TransactionId parseTransactionId(final byte[] transactionId) {
if (transactionId == null) {
throw new NullPointerException("transactionId must not be null");
}
final Buffer buffer = new FixedBuffer(transactionId);
final byte version = buffer.readByte();
if (version != VERSION) {
throw new IllegalArgumentException("invalid Version");
}
final String agentId = buffer.readPrefixedString();
final long agentStartTime = buffer.readVLong();
final long transactionSequence = buffer.readVLong();
if (agentId == null) {
return new TransactionId(agentStartTime, transactionSequence);
} else {
return new TransactionId(agentId, agentStartTime, transactionSequence);
}
}
use of com.navercorp.pinpoint.common.buffer.Buffer in project pinpoint by naver.
the class TransactionIdUtils method writeTransactionId.
private static Buffer writeTransactionId(String agentId, long agentStartTime, long transactionSequence) {
// agentId may be null
// version + prefixed size + string + long + long
final Buffer buffer = new AutomaticBuffer(1 + 5 + 24 + 10 + 10);
buffer.putByte(VERSION);
buffer.putPrefixedString(agentId);
buffer.putVLong(agentStartTime);
buffer.putVLong(transactionSequence);
return buffer;
}
Aggregations