use of com.navercorp.pinpoint.profiler.context.SpanEvent in project pinpoint by naver.
the class SpanStreamSendDataSerializerTest method createSpan.
private Span createSpan(List<SpanEvent> spanEventList) {
DefaultTraceId traceId = new DefaultTraceId("test", 0, 1);
Span span = new Span();
for (SpanEvent spanEvent : spanEventList) {
span.addToSpanEventList(spanEvent);
}
span.setAgentId("agentId");
span.recordTraceId(traceId);
return span;
}
use of com.navercorp.pinpoint.profiler.context.SpanEvent in project pinpoint by naver.
the class SpanStreamSendDataSerializerTest method createSpanEventList.
private List<SpanEvent> createSpanEventList(int size) throws InterruptedException {
Span span = new Span();
List<SpanEvent> spanEventList = new ArrayList<SpanEvent>(size);
for (int i = 0; i < size; i++) {
SpanEvent spanEvent = new SpanEvent(span);
spanEvent.markStartTime();
Thread.sleep(1);
spanEvent.markAfterTime();
spanEventList.add(spanEvent);
}
return spanEventList;
}
use of com.navercorp.pinpoint.profiler.context.SpanEvent in project pinpoint by naver.
the class SpanChunkStreamSendDataPlanerTest method spanChunkStreamSendDataPlanerTest.
@Test
public void spanChunkStreamSendDataPlanerTest() throws Exception {
int spanEventSize = 10;
SpanStreamSendDataSerializer serializer = new SpanStreamSendDataSerializer();
HeaderTBaseSerializerFactory headerTBaseSerializerFactory = new HeaderTBaseSerializerFactory();
List<SpanEvent> originalSpanEventList = createSpanEventList(spanEventSize);
SpanChunk spanChunk = spanChunkFactory.create(originalSpanEventList);
PartitionedByteBufferLocator partitionedByteBufferLocator = serializer.serializeSpanChunkStream(headerTBaseSerializerFactory.createSerializer(), spanChunk);
SpanStreamSendDataFactory factory = new SpanStreamSendDataFactory(100, 50, objectPool);
List<TSpanEvent> spanEventList = getSpanEventList(partitionedByteBufferLocator, factory);
partitionedByteBufferLocator = serializer.serializeSpanChunkStream(headerTBaseSerializerFactory.createSerializer(), spanChunk);
factory = new SpanStreamSendDataFactory(objectPool);
List<TSpanEvent> spanEventList2 = getSpanEventList(partitionedByteBufferLocator, factory);
Assert.assertEquals(spanEventSize, spanEventList.size());
Assert.assertEquals(spanEventSize, spanEventList2.size());
}
use of com.navercorp.pinpoint.profiler.context.SpanEvent in project pinpoint by naver.
the class GrpcSpanMessageConverter method buildPSpanEventList.
private List<PSpanEvent> buildPSpanEventList(List<SpanEvent> spanEventList) {
final int eventSize = spanEventList.size();
final List<PSpanEvent> pSpanEventList = new ArrayList<>(eventSize);
for (SpanEvent spanEvent : spanEventList) {
final PSpanEvent.Builder pSpanEvent = buildPSpanEvent(spanEvent);
pSpanEventList.add(pSpanEvent.build());
}
return pSpanEventList;
}
use of com.navercorp.pinpoint.profiler.context.SpanEvent in project pinpoint by naver.
the class GrpcSpanProcessorV2 method postProcess.
private void postProcess(long keyTime, List<SpanEvent> spanEventList, List<PSpanEvent.Builder> pSpanEventList) {
final int spanEventSize = CollectionUtils.nullSafeSize(spanEventList);
if (spanEventSize == 0) {
return;
}
if (!(spanEventSize == CollectionUtils.nullSafeSize(pSpanEventList))) {
throw new IllegalStateException("list size not same");
}
// check list type
assert spanEventList instanceof RandomAccess;
int prevDepth = 0;
boolean first = true;
final int listSize = spanEventList.size();
for (int i = 0; i < listSize; i++) {
final SpanEvent spanEvent = spanEventList.get(i);
final PSpanEvent.Builder pSpanEvent = pSpanEventList.get(i);
final long startTime = spanEvent.getStartTime();
final long startElapsedTime = startTime - keyTime;
pSpanEvent.setStartElapsed((int) startElapsedTime);
keyTime = startTime;
if (first) {
first = false;
int depth = spanEvent.getDepth();
prevDepth = depth;
pSpanEvent.setDepth(depth);
} else {
int currentDepth = spanEvent.getDepth();
if (currentDepth == prevDepth) {
// skip
pSpanEvent.setDepth(0);
} else {
pSpanEvent.setDepth(currentDepth);
}
prevDepth = currentDepth;
}
}
}
Aggregations