use of com.navercorp.pinpoint.common.server.bo.SpanBo in project pinpoint by naver.
the class SpanIdMatcherTest method testApproximateMatchEqualsCase.
@Test
public void testApproximateMatchEqualsCase() throws Exception {
List<SpanBo> matchSpanList = new ArrayList<SpanBo>();
SpanBo spanBo1 = new SpanBo();
spanBo1.setStartTime(2);
matchSpanList.add(spanBo1);
SpanBo spanBo2 = new SpanBo();
spanBo2.setStartTime(2);
matchSpanList.add(spanBo2);
SpanIdMatcher spanIdMatcher = new SpanIdMatcher(matchSpanList);
SpanBo match = spanIdMatcher.approximateMatch(1);
Assert.assertTrue(match == spanBo1);
Assert.assertEquals(1, spanIdMatcher.other().size());
Assert.assertTrue(spanBo2 == spanIdMatcher.other().get(0));
}
use of com.navercorp.pinpoint.common.server.bo.SpanBo in project pinpoint by naver.
the class SpanHandler method handleSimple.
public void handleSimple(TBase<?, ?> tbase) {
if (!(tbase instanceof TSpan)) {
throw new IllegalArgumentException("unexpected tbase:" + tbase + " expected:" + this.getClass().getName());
}
try {
final TSpan tSpan = (TSpan) tbase;
if (logger.isDebugEnabled()) {
logger.debug("Received SPAN={}", tSpan);
}
final SpanBo spanBo = spanFactory.buildSpanBo(tSpan);
traceDao.insert(spanBo);
applicationTraceIndexDao.insert(tSpan);
// insert statistics info for server map
insertAcceptorHost(spanBo);
insertSpanStat(spanBo);
insertSpanEventStat(spanBo);
} catch (Exception e) {
logger.warn("Span handle error. Caused:{}. Span:{}", e.getMessage(), tbase, e);
}
}
use of com.navercorp.pinpoint.common.server.bo.SpanBo in project pinpoint by naver.
the class SpanDecoderV0 method readSpan.
private SpanBo readSpan(Buffer qualifier, Buffer columnValue, SpanDecodingContext decodingContext) {
final SpanBo span = new SpanBo();
final TransactionId transactionId = decodingContext.getTransactionId();
span.setTransactionId(transactionId);
span.setCollectorAcceptTime(decodingContext.getCollectorAcceptedTime());
SpanEventBo firstSpanEvent = readQualifier(span, qualifier);
readSpanValue(columnValue, span, firstSpanEvent, decodingContext);
return span;
}
use of com.navercorp.pinpoint.common.server.bo.SpanBo in project pinpoint by naver.
the class SpanEncoderV0 method encodeSpanQualifier.
@Override
public ByteBuffer encodeSpanQualifier(SpanEncodingContext<SpanBo> encodingContext) {
final SpanBo spanBo = encodingContext.getValue();
final List<SpanEventBo> spanEventBoList = spanBo.getSpanEventBoList();
final SpanEventBo firstEvent = getFirstSpanEvent(spanEventBoList);
return encodeQualifier(TYPE_SPAN, spanBo.getApplicationId(), spanBo.getAgentId(), spanBo.getAgentStartTime(), spanBo.getSpanId(), firstEvent);
}
use of com.navercorp.pinpoint.common.server.bo.SpanBo 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