use of com.navercorp.pinpoint.profiler.context.SpanEvent in project pinpoint by naver.
the class BufferedStorageTest method testStore_manual_flush.
@Test
public void testStore_manual_flush() throws Exception {
BufferedStorage bufferedStorage = newBufferedStorage(10);
Span span = new Span(internalTraceId);
SpanEvent spanEvent = new SpanEvent();
bufferedStorage.store(spanEvent);
bufferedStorage.store(spanEvent);
bufferedStorage.flush();
Assert.assertEquals(1, countingDataSender.getSenderCounter());
Assert.assertEquals(1, countingDataSender.getTotalCount());
Assert.assertEquals(0, countingDataSender.getSpanCounter());
Assert.assertEquals(1, countingDataSender.getSpanChunkCounter());
}
use of com.navercorp.pinpoint.profiler.context.SpanEvent in project pinpoint by naver.
the class BufferedStorageTest method testStore_Noflush.
@Test
public void testStore_Noflush() throws Exception {
BufferedStorage bufferedStorage = newBufferedStorage(10);
Span span = new Span(internalTraceId);
SpanEvent spanEvent = new SpanEvent();
bufferedStorage.store(spanEvent);
bufferedStorage.store(spanEvent);
Assert.assertEquals(0, countingDataSender.getTotalCount());
}
use of com.navercorp.pinpoint.profiler.context.SpanEvent in project pinpoint by naver.
the class SpanThriftMessageConverterTest method buildTSpanEvent.
@Test
public void buildTSpanEvent() {
final long startTime = System.currentTimeMillis() - 100;
SpanEvent spanEvent = new SpanEvent();
spanEvent.setDepth(RandomExUtils.nextInt(0, 100));
spanEvent.setStartTime(startTime + RandomExUtils.nextInt(0, 100));
spanEvent.setAfterTime(spanEvent.getStartTime() + RandomExUtils.nextInt(5, 100));
spanEvent.setDestinationId("destinationId");
spanEvent.setSequence(RandomExUtils.nextInt(0, 100));
spanEvent.setNextSpanId(RandomExUtils.nextInt(0, 100));
spanEvent.setAsyncIdObject(new DefaultAsyncId(RandomExUtils.nextInt(0, 100)));
spanEvent.addAnnotation(Annotations.of(1));
TSpanEvent tSpanEvent = messageConverter.buildTSpanEvent(spanEvent);
spanPostProcessor.postEventProcess(Collections.singletonList(spanEvent), Collections.singletonList(tSpanEvent), startTime);
Assert.assertEquals(spanEvent.getDepth(), tSpanEvent.getDepth());
Assert.assertEquals(spanEvent.getStartTime(), startTime + tSpanEvent.getStartElapsed());
Assert.assertEquals(spanEvent.getAfterTime(), startTime + tSpanEvent.getStartElapsed() + tSpanEvent.getEndElapsed());
Assert.assertEquals(spanEvent.getDestinationId(), tSpanEvent.getDestinationId());
Assert.assertEquals(spanEvent.getSequence(), tSpanEvent.getSequence());
Assert.assertEquals(spanEvent.getNextSpanId(), tSpanEvent.getNextSpanId());
Assert.assertEquals(spanEvent.getAsyncIdObject().getAsyncId(), tSpanEvent.getNextAsyncId());
Assert.assertEquals(spanEvent.getAnnotations().size(), tSpanEvent.getAnnotations().size());
}
use of com.navercorp.pinpoint.profiler.context.SpanEvent in project pinpoint by naver.
the class SpanThriftMessageConverterTest method buildTSpan.
@Test
public void buildTSpan() {
final Span span = newSpan();
span.setStartTime(System.currentTimeMillis());
span.setElapsedTime(RandomExUtils.nextInt(0, 100));
span.setAcceptorHost("acceptorHost");
span.setExceptionInfo(new IntStringValue(RandomExUtils.nextInt(0, 100), "error"));
span.setApiId(RandomExUtils.nextInt(0, 100));
span.setServiceType((short) RandomExUtils.nextInt(0, 100));
span.setRemoteAddr("remoteAddr");
span.setParentApplicationName("pApp");
span.setParentApplicationType((short) RandomExUtils.nextInt(0, 100));
final TraceRoot traceRoot = span.getTraceRoot();
Shared shared = traceRoot.getShared();
shared.setEndPoint("endPoint");
shared.setRpcName("rpcName");
shared.setLoggingInfo((byte) RandomExUtils.nextInt(0, 10));
shared.maskErrorCode(RandomExUtils.nextInt(0, 100));
shared.setStatusCode(RandomExUtils.nextInt(0, 100));
span.addAnnotation(Annotations.of(1));
span.setSpanEventList(Collections.singletonList(new SpanEvent()));
final TSpan tSpan = messageConverter.buildTSpan(span);
Assert.assertEquals(span.getStartTime(), tSpan.getStartTime());
Assert.assertEquals(span.getElapsedTime(), tSpan.getElapsed());
Assert.assertEquals(span.getAcceptorHost(), tSpan.getAcceptorHost());
Assert.assertEquals(span.getExceptionInfo().getIntValue(), tSpan.getExceptionInfo().getIntValue());
Assert.assertEquals(span.getExceptionInfo().getStringValue(), tSpan.getExceptionInfo().getStringValue());
Assert.assertEquals(span.getApiId(), tSpan.getApiId());
Assert.assertEquals(span.getServiceType(), tSpan.getServiceType());
Assert.assertEquals(span.getRemoteAddr(), tSpan.getRemoteAddr());
Assert.assertEquals(span.getParentApplicationName(), tSpan.getParentApplicationName());
Assert.assertEquals(span.getParentApplicationType(), tSpan.getParentApplicationType());
Assert.assertEquals(traceRoot.getTraceId().getSpanId(), tSpan.getSpanId());
Assert.assertEquals(traceRoot.getShared().getEndPoint(), tSpan.getEndPoint());
Assert.assertEquals(traceRoot.getShared().getRpcName(), tSpan.getRpc());
Assert.assertEquals(traceRoot.getShared().getLoggingInfo(), tSpan.getLoggingTransactionInfo());
Assert.assertEquals(traceRoot.getShared().getErrorCode(), tSpan.getErr());
// TODO
// Assert.assertEquals(traceRoot.getShared().getStatusCode(), );
Assert.assertEquals(span.getAnnotations().size(), tSpan.getAnnotations().size());
Assert.assertEquals(span.getSpanEventList().size(), tSpan.getSpanEventList().size());
}
use of com.navercorp.pinpoint.profiler.context.SpanEvent in project pinpoint by naver.
the class SpanThriftMessageConverterTest method newSpanChunk.
private SpanChunk newSpanChunk() {
final TraceId traceId = new DefaultTraceId(AGENT_ID, AGENT_START_TIME, 1L);
final TraceRoot traceRoot = new DefaultTraceRoot(traceId, AGENT_ID, AGENT_START_TIME, 100L);
return new DefaultSpanChunk(traceRoot, Arrays.asList(new SpanEvent()));
}
Aggregations