Search in sources :

Example 56 with Buffer

use of com.navercorp.pinpoint.common.buffer.Buffer in project pinpoint by naver.

the class SpanEventSerializer method writeValue.

public ByteBuffer writeValue(SpanEventEncodingContext spanEventEncodingContext) {
    SpanEventBo spanEventBo = spanEventEncodingContext.getSpanEventBo();
    BasicSpan basicSpan = spanEventEncodingContext.getBasicSpan();
    final Buffer buffer = new AutomaticBuffer(512);
    buffer.putByte(spanEventBo.getVersion());
    buffer.putPrefixedString(basicSpan.getAgentId());
    buffer.putPrefixedString(basicSpan.getApplicationId());
    buffer.putVLong(basicSpan.getAgentStartTime());
    buffer.putVInt(spanEventBo.getStartElapsed());
    buffer.putVInt(spanEventBo.getEndElapsed());
    // don't need to put sequence because it is set at Qualifier
    // buffer.put(sequence);
    buffer.putPrefixedString(spanEventBo.getRpc());
    buffer.putShort(spanEventBo.getServiceType());
    buffer.putPrefixedString(spanEventBo.getEndPoint());
    buffer.putPrefixedString(spanEventBo.getDestinationId());
    buffer.putSVInt(spanEventBo.getApiId());
    buffer.putSVInt(spanEventBo.getDepth());
    buffer.putLong(spanEventBo.getNextSpanId());
    if (spanEventBo.hasException()) {
        buffer.putBoolean(true);
        buffer.putSVInt(spanEventBo.getExceptionId());
        buffer.putPrefixedString(spanEventBo.getExceptionMessage());
    } else {
        buffer.putBoolean(false);
    }
    final List<AnnotationBo> annotationBoList = spanEventBo.getAnnotationBoList();
    this.annotationSerializer.writeAnnotationList(annotationBoList, buffer);
    buffer.putSVInt(spanEventBo.getNextAsyncId());
    return buffer.wrapByteBuffer();
}
Also used : Buffer(com.navercorp.pinpoint.common.buffer.Buffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) ByteBuffer(java.nio.ByteBuffer) AnnotationBo(com.navercorp.pinpoint.common.server.bo.AnnotationBo) BasicSpan(com.navercorp.pinpoint.common.server.bo.BasicSpan) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) SpanEventBo(com.navercorp.pinpoint.common.server.bo.SpanEventBo)

Example 57 with Buffer

use of com.navercorp.pinpoint.common.buffer.Buffer in project pinpoint by naver.

the class SpanSerializer method writeColumnValue.

// Variable encoding has been added in case of write io operation. The data size can be reduced by about 10%.
public ByteBuffer writeColumnValue(SpanBo span) {
    /*
           It is difficult to calculate the size of buffer. It's not impossible.
           However just use automatic incremental buffer for convenience's sake.
           Consider to reuse getBufferLength when memory can be used more efficiently later.
        */
    final Buffer buffer = new AutomaticBuffer(256);
    buffer.putByte(span.getRawVersion());
    buffer.putPrefixedString(span.getAgentId());
    // Using var makes the sie of time smaller based on the present time. That consumes only 6 bytes.
    buffer.putVLong(span.getAgentStartTime());
    // insert for rowkey
    // buffer.put(spanID);
    buffer.putLong(span.getParentSpanId());
    // use var encoding because of based on the present time
    buffer.putVLong(span.getStartTime());
    buffer.putVInt(span.getElapsed());
    buffer.putPrefixedString(span.getRpc());
    buffer.putPrefixedString(span.getApplicationId());
    buffer.putShort(span.getServiceType());
    buffer.putPrefixedString(span.getEndPoint());
    buffer.putPrefixedString(span.getRemoteAddr());
    buffer.putSVInt(span.getApiId());
    // errCode value may be negative
    buffer.putSVInt(span.getErrCode());
    if (span.hasException()) {
        buffer.putBoolean(true);
        buffer.putSVInt(span.getExceptionId());
        buffer.putPrefixedString(span.getExceptionMessage());
    } else {
        buffer.putBoolean(false);
    }
    buffer.putShort(span.getFlag());
    if (span.hasApplicationServiceType()) {
        buffer.putBoolean(true);
        buffer.putShort(span.getApplicationServiceType());
    } else {
        buffer.putBoolean(false);
    }
    buffer.putByte(span.getLoggingTransactionInfo());
    buffer.putPrefixedString(span.getAcceptorHost());
    return buffer.wrapByteBuffer();
}
Also used : Buffer(com.navercorp.pinpoint.common.buffer.Buffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) ByteBuffer(java.nio.ByteBuffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer)

Example 58 with Buffer

use of com.navercorp.pinpoint.common.buffer.Buffer in project pinpoint by naver.

the class SpanEncoderV0 method encodeQualifier.

private ByteBuffer encodeQualifier(byte type, String applicationId, String agentId, long agentStartTime, long spanId, SpanEventBo firstEvent) {
    final Buffer buffer = new AutomaticBuffer(128);
    buffer.putByte(type);
    buffer.putPrefixedString(applicationId);
    buffer.putPrefixedString(agentId);
    buffer.putVLong(agentStartTime);
    buffer.putLong(spanId);
    if (firstEvent != null) {
        buffer.putSVInt(firstEvent.getSequence());
        final byte bitField = SpanEventQualifierBitField.buildBitField(firstEvent);
        buffer.putByte(bitField);
        // case : async span
        if (SpanEventQualifierBitField.isSetAsync(bitField)) {
            buffer.putInt(firstEvent.getAsyncId());
            buffer.putVInt(firstEvent.getAsyncSequence());
        }
    } else {
    // simple trace case
    //            buffer.putSVInt((short) -1);
    //            byte cfBitField = SpanEventQualifierBitField.setAsync((byte) 0, false);
    //            buffer.putByte(cfBitField);
    }
    return buffer.wrapByteBuffer();
}
Also used : Buffer(com.navercorp.pinpoint.common.buffer.Buffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) ByteBuffer(java.nio.ByteBuffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer)

Example 59 with Buffer

use of com.navercorp.pinpoint.common.buffer.Buffer in project pinpoint by naver.

the class SpanUtils method getVarTransactionId.

public static byte[] getVarTransactionId(TSpan span) {
    if (span == null) {
        throw new NullPointerException("span must not be null");
    }
    final byte[] transactionIdBytes = span.getTransactionId();
    TransactionId transactionId = TransactionIdUtils.parseTransactionId(transactionIdBytes);
    String agentId = transactionId.getAgentId();
    if (agentId == null) {
        agentId = span.getAgentId();
    }
    final Buffer buffer = new AutomaticBuffer(32);
    buffer.putPrefixedString(agentId);
    buffer.putSVLong(transactionId.getAgentStartTime());
    buffer.putVLong(transactionId.getTransactionSequence());
    return buffer.getBuffer();
}
Also used : Buffer(com.navercorp.pinpoint.common.buffer.Buffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) TransactionId(com.navercorp.pinpoint.common.util.TransactionId)

Example 60 with Buffer

use of com.navercorp.pinpoint.common.buffer.Buffer in project pinpoint by naver.

the class AgentStatCpuLoadBo method writeValue.

public byte[] writeValue() {
    final Buffer buffer = new AutomaticBuffer();
    buffer.putPrefixedString(this.agentId);
    buffer.putLong(this.startTimestamp);
    buffer.putLong(this.timestamp);
    buffer.putDouble(this.jvmCpuLoad);
    buffer.putDouble(this.systemCpuLoad);
    return buffer.getBuffer();
}
Also used : FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) Buffer(com.navercorp.pinpoint.common.buffer.Buffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer)

Aggregations

Buffer (com.navercorp.pinpoint.common.buffer.Buffer)107 AutomaticBuffer (com.navercorp.pinpoint.common.buffer.AutomaticBuffer)76 FixedBuffer (com.navercorp.pinpoint.common.buffer.FixedBuffer)57 ByteBuffer (java.nio.ByteBuffer)27 Test (org.junit.Test)24 OffsetFixedBuffer (com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer)15 ApplicationStatDecodingContext (com.navercorp.pinpoint.common.server.bo.serializer.stat.ApplicationStatDecodingContext)11 JoinStatBo (com.navercorp.pinpoint.common.server.bo.stat.join.JoinStatBo)11 AgentStatDataPointCodec (com.navercorp.pinpoint.common.server.bo.codec.stat.AgentStatDataPointCodec)10 Date (java.util.Date)10 SpanEventBo (com.navercorp.pinpoint.common.server.bo.SpanEventBo)9 Cell (org.apache.hadoop.hbase.Cell)9 SpanBo (com.navercorp.pinpoint.common.server.bo.SpanBo)8 ArrayList (java.util.ArrayList)6 AnnotationBo (com.navercorp.pinpoint.common.server.bo.AnnotationBo)5 TransactionId (com.navercorp.pinpoint.common.profiler.util.TransactionId)4 IntStringStringValue (com.navercorp.pinpoint.common.util.IntStringStringValue)4 TransactionId (com.navercorp.pinpoint.common.util.TransactionId)4 Put (org.apache.hadoop.hbase.client.Put)4 SpanChunkBo (com.navercorp.pinpoint.common.server.bo.SpanChunkBo)3