use of com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.bitfield.SpanBitFiled in project pinpoint by naver.
the class SpanDecoderV0 method readSpanValue.
public void readSpanValue(Buffer buffer, SpanBo span, SpanEventBo firstSpanEvent, SpanDecodingContext decodingContext) {
final byte version = buffer.readByte();
if (version != 0) {
throw new IllegalStateException("unknown version :" + version);
}
span.setVersion(version);
final SpanBitFiled bitFiled = new SpanBitFiled(buffer.readByte());
final short serviceType = buffer.readShort();
span.setServiceType(serviceType);
switch(bitFiled.getApplicationServiceTypeEncodingStrategy()) {
case PREV_EQUALS:
span.setApplicationServiceType(serviceType);
break;
case RAW:
span.setApplicationServiceType(buffer.readShort());
break;
default:
throw new IllegalStateException("applicationServiceType");
}
if (!bitFiled.isRoot()) {
span.setParentSpanId(buffer.readLong());
} else {
span.setParentSpanId(-1);
}
final long startTimeDelta = buffer.readVLong();
final long startTime = span.getCollectorAcceptTime() - startTimeDelta;
span.setStartTime(startTime);
span.setElapsed(buffer.readVInt());
span.setRpc(buffer.readPrefixedString());
span.setEndPoint(buffer.readPrefixedString());
span.setRemoteAddr(buffer.readPrefixedString());
span.setApiId(buffer.readSVInt());
if (bitFiled.isSetErrorCode()) {
span.setErrCode(buffer.readInt());
}
if (bitFiled.isSetHasException()) {
int exceptionId = buffer.readSVInt();
String exceptionMessage = buffer.readPrefixedString();
span.setExceptionInfo(exceptionId, exceptionMessage);
}
if (bitFiled.isSetFlag()) {
span.setFlag(buffer.readShort());
}
if (bitFiled.isSetLoggingTransactionInfo()) {
span.setLoggingTransactionInfo(buffer.readByte());
}
span.setAcceptorHost(buffer.readPrefixedString());
if (bitFiled.isSetAnnotation()) {
List<AnnotationBo> annotationBoList = readAnnotationList(buffer, decodingContext);
span.setAnnotationBoList(annotationBoList);
}
List<SpanEventBo> spanEventBoList = readSpanEvent(buffer, firstSpanEvent, decodingContext);
span.addSpanEventBoList(spanEventBoList);
}
use of com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.bitfield.SpanBitFiled 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();
}
Aggregations