use of com.navercorp.pinpoint.common.buffer.AutomaticBuffer in project pinpoint by naver.
the class AgentLifeCycleValueMapper method mapValue.
@Override
public byte[] mapValue(AgentLifeCycleBo value) {
final Buffer buffer = new AutomaticBuffer();
buffer.putInt(value.getVersion());
buffer.putPrefixedString(value.getAgentId());
buffer.putLong(value.getStartTimestamp());
buffer.putLong(value.getEventTimestamp());
buffer.putLong(value.getEventIdentifier());
buffer.putShort(value.getAgentLifeCycleState().getCode());
return buffer.getBuffer();
}
use of com.navercorp.pinpoint.common.buffer.AutomaticBuffer in project pinpoint by naver.
the class SpanEncoderV0 method encodeQualifier.
private ByteBuffer encodeQualifier(byte type, BasicSpan basicSpan, SpanEventBo firstEvent, LocalAsyncIdBo localAsyncId) {
final Buffer buffer = new AutomaticBuffer(128);
buffer.putByte(type);
buffer.putPrefixedString(basicSpan.getApplicationId());
buffer.putPrefixedString(basicSpan.getAgentId());
buffer.putVLong(basicSpan.getAgentStartTime());
buffer.putLong(basicSpan.getSpanId());
if (firstEvent != null) {
buffer.putSVInt(firstEvent.getSequence());
final byte bitField = SpanEventQualifierBitField.buildBitField(localAsyncId);
buffer.putByte(bitField);
// case : async span
if (SpanEventQualifierBitField.isSetAsync(bitField)) {
buffer.putInt(localAsyncId.getAsyncId());
buffer.putVInt(localAsyncId.getSequence());
}
} else {
// simple trace case
// buffer.putSVInt((short) -1);
// byte cfBitField = SpanEventQualifierBitField.setAsync((byte) 0, false);
// buffer.putByte(cfBitField);
}
return buffer.wrapByteBuffer();
}
use of com.navercorp.pinpoint.common.buffer.AutomaticBuffer 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();
}
use of com.navercorp.pinpoint.common.buffer.AutomaticBuffer in project pinpoint by naver.
the class HbaseApplicationTraceIndexDao method insert.
@Override
public void insert(final SpanBo span) {
Objects.requireNonNull(span, "span");
if (logger.isDebugEnabled()) {
logger.debug("insert ApplicationTraceIndex: {}", span);
}
// Assert agentId
CollectorUtils.checkAgentId(span.getAgentId());
// Assert applicationName
CollectorUtils.checkApplicationName(span.getApplicationId());
final Buffer buffer = new AutomaticBuffer(10 + HbaseTableConstants.AGENT_ID_MAX_LEN);
buffer.putVInt(span.getElapsed());
buffer.putSVInt(span.getErrCode());
buffer.putPrefixedString(span.getAgentId());
final byte[] value = buffer.getBuffer();
final long acceptedTime = acceptedTimeService.getAcceptedTime();
final byte[] distributedKey = createRowKey(span, acceptedTime);
final Put put = new Put(distributedKey);
put.addColumn(DESCRIPTOR.getName(), makeQualifier(span), acceptedTime, value);
final TableName applicationTraceIndexTableName = tableNameProvider.getTableName(DESCRIPTOR.getTable());
hbaseTemplate.asyncPut(applicationTraceIndexTableName, put);
}
use of com.navercorp.pinpoint.common.buffer.AutomaticBuffer in project pinpoint by naver.
the class EncodingStrategyTestBase method testStrategy.
public <T> void testStrategy(List<T> expectedValues, EncodingStrategy<T> strategy) {
Buffer encodeBuffer = new AutomaticBuffer();
strategy.encodeValues(encodeBuffer, expectedValues);
Buffer decodeBuffer = new FixedBuffer(encodeBuffer.getBuffer());
List<T> actualValues = strategy.decodeValues(decodeBuffer, expectedValues.size());
Assert.assertEquals(expectedValues, actualValues);
}
Aggregations