Search in sources :

Example 11 with SpanType

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;
}
Also used : SpanType(com.navercorp.pinpoint.profiler.context.SpanType) SpanChunk(com.navercorp.pinpoint.profiler.context.SpanChunk) ArrayList(java.util.ArrayList) SpanEvent(com.navercorp.pinpoint.profiler.context.SpanEvent) ArrayList(java.util.ArrayList) List(java.util.List) Span(com.navercorp.pinpoint.profiler.context.Span)

Example 12 with SpanType

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);
}
Also used : SpanType(com.navercorp.pinpoint.profiler.context.SpanType) SpanEvent(com.navercorp.pinpoint.profiler.context.SpanEvent)

Example 13 with SpanType

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;
}
Also used : SpanType(com.navercorp.pinpoint.profiler.context.SpanType) ActualTrace(com.navercorp.pinpoint.test.wrapper.ActualTrace)

Example 14 with SpanType

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());
}
Also used : PrintStream(java.io.PrintStream) SpanType(com.navercorp.pinpoint.profiler.context.SpanType) DefaultTraceId(com.navercorp.pinpoint.profiler.context.id.DefaultTraceId) DefaultTraceRoot(com.navercorp.pinpoint.profiler.context.id.DefaultTraceRoot) DefaultSpanChunk(com.navercorp.pinpoint.profiler.context.DefaultSpanChunk) SpanChunk(com.navercorp.pinpoint.profiler.context.SpanChunk) DefaultAsyncSpanChunk(com.navercorp.pinpoint.profiler.context.DefaultAsyncSpanChunk) TraceId(com.navercorp.pinpoint.bootstrap.context.TraceId) DefaultTraceId(com.navercorp.pinpoint.profiler.context.id.DefaultTraceId) DefaultLocalAsyncId(com.navercorp.pinpoint.profiler.context.DefaultLocalAsyncId) DefaultTraceRoot(com.navercorp.pinpoint.profiler.context.id.DefaultTraceRoot) TraceRoot(com.navercorp.pinpoint.profiler.context.id.TraceRoot) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Span(com.navercorp.pinpoint.profiler.context.Span) Test(org.junit.Test)

Example 15 with SpanType

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);
    }
}
Also used : SpanType(com.navercorp.pinpoint.profiler.context.SpanType) ThriftMessageSerializer(com.navercorp.pinpoint.profiler.sender.ThriftMessageSerializer) PinpointClientFactory(com.navercorp.pinpoint.rpc.client.PinpointClientFactory) TcpDataSender(com.navercorp.pinpoint.profiler.sender.TcpDataSender) UdpDataSenderFactory(com.navercorp.pinpoint.profiler.sender.UdpDataSenderFactory)

Aggregations

SpanType (com.navercorp.pinpoint.profiler.context.SpanType)15 SpanChunk (com.navercorp.pinpoint.profiler.context.SpanChunk)5 TraceRoot (com.navercorp.pinpoint.profiler.context.id.TraceRoot)5 Span (com.navercorp.pinpoint.profiler.context.Span)4 TraceId (com.navercorp.pinpoint.bootstrap.context.TraceId)3 DefaultAsyncSpanChunk (com.navercorp.pinpoint.profiler.context.DefaultAsyncSpanChunk)3 DefaultLocalAsyncId (com.navercorp.pinpoint.profiler.context.DefaultLocalAsyncId)3 DefaultSpanChunk (com.navercorp.pinpoint.profiler.context.DefaultSpanChunk)3 SpanEvent (com.navercorp.pinpoint.profiler.context.SpanEvent)3 DefaultTraceId (com.navercorp.pinpoint.profiler.context.id.DefaultTraceId)3 DefaultTraceRoot (com.navercorp.pinpoint.profiler.context.id.DefaultTraceRoot)3 PinpointClientFactory (com.navercorp.pinpoint.rpc.client.PinpointClientFactory)3 ActualTrace (com.navercorp.pinpoint.test.wrapper.ActualTrace)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 PrintStream (java.io.PrintStream)3 Test (org.junit.Test)3 TypeLiteral (com.google.inject.TypeLiteral)2 ExpectedTrace (com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedTrace)2 ServerMetaDataRegistryService (com.navercorp.pinpoint.profiler.context.ServerMetaDataRegistryService)2 MetaDataType (com.navercorp.pinpoint.profiler.metadata.MetaDataType)2