use of com.navercorp.pinpoint.profiler.context.SpanChunk in project pinpoint by naver.
the class OrderedSpanRecorderTest method testMultipleAsyncSpanEvents.
@Test
public void testMultipleAsyncSpanEvents() {
// given
final long startTime1 = 100;
final long spanId = 1L;
TraceId traceId1 = new DefaultTraceId(agentId, startTime1, 0, -1L, spanId, (short) 0);
final TraceRoot traceRoot1 = new DefaultTraceRoot(traceId1, agentId, startTime1, 0);
final long startTime2 = startTime1 + 10L;
final long spanId2 = 2L;
final TraceId traceId2 = new DefaultTraceId(agentId, startTime2, 0, -1L, spanId2, (short) 0);
final TraceRoot traceRoot2 = new DefaultTraceRoot(traceId2, agentId, startTime2, 0);
Span span = createSpan(traceRoot1, startTime1);
SpanChunk event1 = wrapSpanChunk(traceRoot1, createSpanEvent(traceRoot1, 0, 0));
SpanChunk asyncEvent1_1_1 = wrapSpanChunk(traceRoot1, createAsyncSpanEvent(traceRoot1, 0, 0), new DefaultLocalAsyncId(1, (short) 1));
SpanChunk asyncEvent1_1_2 = wrapSpanChunk(traceRoot1, createAsyncSpanEvent(traceRoot1, 0, 1), new DefaultLocalAsyncId(1, (short) 1));
SpanChunk asyncEvent1_2_1 = wrapSpanChunk(traceRoot1, createAsyncSpanEvent(traceRoot1, 0, 0), new DefaultLocalAsyncId(1, (short) 2));
SpanChunk event2 = wrapSpanChunk(traceRoot2, createSpanEvent(traceRoot2, 0, 1));
SpanChunk asyncEvent2_1 = wrapSpanChunk(traceRoot2, createAsyncSpanEvent(traceRoot2, 0, 0), new DefaultLocalAsyncId(2, (short) 1));
SpanChunk asyncEvent2_2 = wrapSpanChunk(traceRoot2, createAsyncSpanEvent(traceRoot2, 0, 0), new DefaultLocalAsyncId(2, (short) 2));
final List<SpanType> expectedOrder = Arrays.asList(span, event1, event2, asyncEvent1_1_1, asyncEvent1_1_2, asyncEvent1_2_1, asyncEvent2_1, asyncEvent2_2);
// when
final List<SpanType> listToBeHandled = Arrays.asList(span, event1, asyncEvent1_1_1, asyncEvent1_1_2, asyncEvent1_2_1, event2, asyncEvent2_1, asyncEvent2_2);
Collections.shuffle(listToBeHandled);
for (SpanType base : listToBeHandled) {
this.recorder.handleSend(base);
}
// then
ByteArrayOutputStream baos = new ByteArrayOutputStream();
this.recorder.print(new PrintStream(baos));
this.logger.debug(baos.toString());
for (SpanType expectedBase : expectedOrder) {
SpanType actualBase = this.recorder.pop();
assertSame(expectedBase, actualBase);
}
assertNull(this.recorder.pop());
}
use of com.navercorp.pinpoint.profiler.context.SpanChunk in project pinpoint by naver.
the class SpanThriftMessageConverterTest method buildTSpanChunk.
@Test
public void buildTSpanChunk() {
final SpanChunk spanChunk = newSpanChunk();
TraceRoot traceRoot = spanChunk.getTraceRoot();
TSpanChunk tSpanChunk = messageConverter.buildTSpanChunk(spanChunk);
Assert.assertEquals(traceRoot.getTraceId().getSpanId(), tSpanChunk.getSpanId());
Assert.assertEquals(traceRoot.getShared().getEndPoint(), tSpanChunk.getEndPoint());
}
use of com.navercorp.pinpoint.profiler.context.SpanChunk in project pinpoint by naver.
the class SpanPostProcessorTest method postProcess2.
@Test
public void postProcess2() {
SpanProcessor<TSpan, TSpanChunk> spanChunkPostProcessor = new SpanProcessorV1();
TraceRoot internalTraceId = newInternalTraceId();
List<TSpanEvent> tSpanEvents = new ArrayList<TSpanEvent>();
TSpanChunk tSpanChunk = new TSpanChunk();
tSpanChunk.setSpanEventList(tSpanEvents);
List<SpanEvent> spanEvents = new ArrayList<SpanEvent>();
SpanChunk spanChunk = new DefaultSpanChunk(internalTraceId, spanEvents);
// one spanEvent
addSpanEvent(tSpanEvents, spanEvents);
spanChunkPostProcessor.postProcess(spanChunk, tSpanChunk);
// two spanEvent
addSpanEvent(tSpanEvents, spanEvents);
spanChunkPostProcessor.postProcess(spanChunk, tSpanChunk);
// three
addSpanEvent(tSpanEvents, spanEvents);
spanChunkPostProcessor.postProcess(spanChunk, tSpanChunk);
}
Aggregations