Search in sources :

Example 1 with SpanChunk

use of com.navercorp.pinpoint.profiler.context.SpanChunk in project pinpoint by naver.

the class GrpcSpanMessageConverter method toMessage.

@Override
public GeneratedMessageV3 toMessage(SpanType message) {
    if (message instanceof SpanChunk) {
        final SpanChunk spanChunk = (SpanChunk) message;
        final PSpanChunk pSpanChunk = buildPSpanChunk(spanChunk);
        return pSpanChunk;
    }
    if (message instanceof Span) {
        final Span span = (Span) message;
        return buildPSpan(span);
    }
    return null;
}
Also used : AsyncSpanChunk(com.navercorp.pinpoint.profiler.context.AsyncSpanChunk) PSpanChunk(com.navercorp.pinpoint.grpc.trace.PSpanChunk) SpanChunk(com.navercorp.pinpoint.profiler.context.SpanChunk) PSpanChunk(com.navercorp.pinpoint.grpc.trace.PSpanChunk) PSpan(com.navercorp.pinpoint.grpc.trace.PSpan) Span(com.navercorp.pinpoint.profiler.context.Span)

Example 2 with SpanChunk

use of com.navercorp.pinpoint.profiler.context.SpanChunk in project pinpoint by naver.

the class OrderedSpanRecorderTest method testOrderingWithSameEventTime.

@Test
public void testOrderingWithSameEventTime() {
    // given
    final long startTime = 100;
    final long spanId = 1L;
    TraceId traceId = new DefaultTraceId(agentId, startTime, 0, -1L, spanId, (short) 0);
    final TraceRoot traceRoot = new DefaultTraceRoot(traceId, agentId, startTime, 0);
    Span span = createSpan(traceRoot, startTime);
    SpanChunk event = wrapSpanChunk(traceRoot, createSpanEvent(traceRoot, 0, 0));
    SpanChunk event1 = wrapSpanChunk(traceRoot, createSpanEvent(traceRoot, 0, 1));
    SpanChunk event2 = wrapSpanChunk(traceRoot, createSpanEvent(traceRoot, 0, 2));
    SpanChunk asyncEvent1_1 = wrapSpanChunk(traceRoot, createAsyncSpanEvent(traceRoot, 0, 0), new DefaultLocalAsyncId(1, (short) 1));
    SpanChunk asyncEvent1_2 = wrapSpanChunk(traceRoot, createAsyncSpanEvent(traceRoot, 0, 1), new DefaultLocalAsyncId(1, (short) 1));
    SpanChunk asyncEvent2 = wrapSpanChunk(traceRoot, createAsyncSpanEvent(traceRoot, 0, 0), new DefaultLocalAsyncId(2, (short) 1));
    final List<SpanType> expectedOrder = Arrays.asList(span, event, event1, event2, asyncEvent1_1, asyncEvent1_2, asyncEvent2);
    // when
    final List<SpanType> listToBeHandled = Arrays.asList(span, event, event1, event2, asyncEvent1_1, asyncEvent1_2, asyncEvent2);
    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 3 with SpanChunk

use of com.navercorp.pinpoint.profiler.context.SpanChunk in project pinpoint by naver.

the class OrderedSpanRecorderTest method testMultipleSpanOrdering.

@Test
public void testMultipleSpanOrdering() {
    // given
    final long startTime1 = 100;
    final long spanId1 = 1L;
    final TraceId traceId1 = new DefaultTraceId(agentId, startTime1, 0, -1L, spanId1, (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 span1 = createSpan(traceRoot1, startTime1);
    SpanChunk event1_0 = wrapSpanChunk(traceRoot1, createSpanEvent(traceRoot1, 1, 0));
    SpanChunk event1_1 = wrapSpanChunk(traceRoot1, createSpanEvent(traceRoot1, 2, 1));
    SpanChunk asyncEvent1_0 = wrapSpanChunk(traceRoot1, createAsyncSpanEvent(traceRoot1, 1, 0), new DefaultLocalAsyncId(1, (short) 1));
    SpanChunk asyncEvent1_1 = wrapSpanChunk(traceRoot1, createAsyncSpanEvent(traceRoot1, 2, 1), new DefaultLocalAsyncId(1, (short) 1));
    Span span2 = createSpan(traceRoot2, startTime2);
    SpanChunk event2_0 = wrapSpanChunk(traceRoot2, createSpanEvent(traceRoot2, 0, 0));
    SpanChunk event2_1 = wrapSpanChunk(traceRoot2, createSpanEvent(traceRoot2, 1, 1));
    SpanChunk asyncEvent2_0 = wrapSpanChunk(traceRoot2, createAsyncSpanEvent(traceRoot2, 0, 0), new DefaultLocalAsyncId(2, (short) 1));
    final List<SpanType> expectedOrder = Arrays.asList(span1, event1_0, event1_1, span2, event2_0, event2_1, asyncEvent1_0, asyncEvent1_1, asyncEvent2_0);
    // when
    final List<SpanType> listToBeHandled = Arrays.asList(span1, event1_0, event1_1, span2, event2_0, event2_1, asyncEvent1_0, asyncEvent1_1, asyncEvent2_0);
    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 4 with SpanChunk

use of com.navercorp.pinpoint.profiler.context.SpanChunk in project pinpoint by naver.

the class SpanPostProcessorTest method postProcess1.

@Test
public void postProcess1() {
    SpanProcessor<TSpan, TSpanChunk> spanChunkPostProcessor = new SpanProcessorV1();
    TraceRoot internalTraceId = newInternalTraceId();
    TSpanChunk tSpanChunk = new TSpanChunk();
    try {
        SpanChunk spanChunk = new DefaultSpanChunk(internalTraceId, new ArrayList<SpanEvent>());
        spanChunkPostProcessor.postProcess(spanChunk, tSpanChunk);
        Assert.fail();
    } catch (Exception ignored) {
    }
}
Also used : TSpanChunk(com.navercorp.pinpoint.thrift.dto.TSpanChunk) DefaultSpanChunk(com.navercorp.pinpoint.profiler.context.DefaultSpanChunk) SpanChunk(com.navercorp.pinpoint.profiler.context.SpanChunk) TSpanChunk(com.navercorp.pinpoint.thrift.dto.TSpanChunk) SpanEvent(com.navercorp.pinpoint.profiler.context.SpanEvent) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) TSpan(com.navercorp.pinpoint.thrift.dto.TSpan) DefaultTraceRoot(com.navercorp.pinpoint.profiler.context.id.DefaultTraceRoot) TraceRoot(com.navercorp.pinpoint.profiler.context.id.TraceRoot) DefaultSpanChunk(com.navercorp.pinpoint.profiler.context.DefaultSpanChunk) Test(org.junit.Test)

Example 5 with SpanChunk

use of com.navercorp.pinpoint.profiler.context.SpanChunk in project pinpoint by naver.

the class PluginVerifierExternalAdaptor method getServiceTypeCode.

private short getServiceTypeCode(SpanType spanType) {
    if (spanType instanceof Span) {
        final Span span = (Span) spanType;
        return span.getServiceType();
    }
    if (spanType instanceof SpanChunk) {
        final SpanChunk spanChunk = (SpanChunk) spanType;
        List<SpanEvent> spanEventList = spanChunk.getSpanEventList();
        if (spanEventList.size() != 1) {
            throw new IllegalStateException("unexpected spanEventList.size() !=1");
        }
        SpanEvent spanEvent = spanEventList.get(0);
        return spanEvent.getServiceType();
    }
    return -1;
}
Also used : SpanChunk(com.navercorp.pinpoint.profiler.context.SpanChunk) SpanEvent(com.navercorp.pinpoint.profiler.context.SpanEvent) Span(com.navercorp.pinpoint.profiler.context.Span)

Aggregations

SpanChunk (com.navercorp.pinpoint.profiler.context.SpanChunk)13 Test (org.junit.Test)8 SpanEvent (com.navercorp.pinpoint.profiler.context.SpanEvent)7 DefaultSpanChunk (com.navercorp.pinpoint.profiler.context.DefaultSpanChunk)6 Span (com.navercorp.pinpoint.profiler.context.Span)6 DefaultTraceRoot (com.navercorp.pinpoint.profiler.context.id.DefaultTraceRoot)6 TraceRoot (com.navercorp.pinpoint.profiler.context.id.TraceRoot)6 SpanType (com.navercorp.pinpoint.profiler.context.SpanType)5 TSpanChunk (com.navercorp.pinpoint.thrift.dto.TSpanChunk)5 TSpanEvent (com.navercorp.pinpoint.thrift.dto.TSpanEvent)5 TraceId (com.navercorp.pinpoint.bootstrap.context.TraceId)3 DefaultAsyncSpanChunk (com.navercorp.pinpoint.profiler.context.DefaultAsyncSpanChunk)3 DefaultLocalAsyncId (com.navercorp.pinpoint.profiler.context.DefaultLocalAsyncId)3 DefaultTraceId (com.navercorp.pinpoint.profiler.context.id.DefaultTraceId)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 PrintStream (java.io.PrintStream)3 ArrayList (java.util.ArrayList)3 TSpan (com.navercorp.pinpoint.thrift.dto.TSpan)2 HeaderTBaseSerializerFactory (com.navercorp.pinpoint.thrift.io.HeaderTBaseSerializerFactory)2 PSpan (com.navercorp.pinpoint.grpc.trace.PSpan)1