use of com.navercorp.pinpoint.profiler.context.SpanType in project pinpoint by naver.
the class ApplicationContextHandler method getExecutedMethod.
public List<String> getExecutedMethod() {
List<String> list = new ArrayList<>();
for (SpanType item : orderedSpanRecorder) {
if (item instanceof Span) {
Span span = (Span) item;
List<SpanEvent> spanEventList = span.getSpanEventList();
addApiDescription(list, spanEventList);
} else if (item instanceof SpanChunk) {
SpanChunk spanChunk = (SpanChunk) item;
List<SpanEvent> spanEventList = spanChunk.getSpanEventList();
addApiDescription(list, spanEventList);
}
}
return list;
}
use of com.navercorp.pinpoint.profiler.context.SpanType in project pinpoint by naver.
the class OrderedSpanRecorder method handleSpanEvent.
private void handleSpanEvent(SpanChunk spanChunk) {
List<SpanEvent> spanEventList = spanChunk.getSpanEventList();
if (spanEventList.size() != 1) {
throw new IllegalStateException("spanEvent.size != 1");
}
final SpanEvent event = spanEventList.get(0);
long startTime = event.getStartTime();
Item<SpanType> item = new Item<SpanType>(spanChunk, startTime, spanChunk.getTraceRoot(), event.getSequence());
insertItem(item);
}
use of com.navercorp.pinpoint.profiler.context.SpanType in project pinpoint by naver.
the class PluginVerifierExternalAdaptor method hasTrace.
private boolean hasTrace(ExpectedTrace expectedTrace) {
if (expectedTrace == null) {
return false;
}
ResolvedExpectedTrace resolvedExpectedTrace = resolveExpectedTrace(expectedTrace, null);
Iterator<SpanType> iterator = this.handler.getOrderedSpanRecorder().iterator();
while (iterator.hasNext()) {
try {
SpanType value = iterator.next();
ActualTrace actualTrace = ActualTraceFactory.wrapOrNull(value);
if (actualTrace == null) {
continue;
}
verifySpan(resolvedExpectedTrace, actualTrace);
return true;
} catch (Throwable ignore) {
}
}
return false;
}
use of com.navercorp.pinpoint.profiler.context.SpanType 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.SpanType in project pinpoint by naver.
the class SpanDataSenderProvider method get.
@Override
public DataSender<SpanType> get() {
if ("TCP".equalsIgnoreCase(transportType)) {
if ("OIO".equalsIgnoreCase(ioType)) {
logger.warn("TCP transport not support OIO type.(only support NIO)");
}
PinpointClientFactory pinpointClientFactory = clientFactoryProvider.get();
MessageSerializer<SpanType, byte[]> messageSerializer = new ThriftMessageSerializer<>(messageConverter);
return new TcpDataSender<>("SpanDataSender", ip, port, pinpointClientFactory, messageSerializer, writeQueueSize);
} else {
UdpDataSenderFactory<SpanType> factory = new UdpDataSenderFactory<>(ip, port, UDP_EXECUTOR_NAME, writeQueueSize, timeout, sendBufferSize, messageConverter);
return factory.create(ioType);
}
}
Aggregations