Search in sources :

Example 6 with DefaultTraceRoot

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

the class SpanEventTest method testMarkStartTime.

@Test
public void testMarkStartTime() {
    final DefaultTraceId traceId = new DefaultTraceId("agentId", 0, 0);
    TraceRoot traceRoot = new DefaultTraceRoot(traceId, "agentId", System.currentTimeMillis(), 0);
    Span span = new Span(traceRoot);
    span.markBeforeTime();
    span.setElapsedTime((int) (span.getStartTime() + 10));
    logger.debug("span:{}", span);
    final SpanEvent spanEvent = new SpanEvent();
    long currentTime = System.currentTimeMillis();
    spanEvent.setStartTime(currentTime);
    spanEvent.setElapsedTime(10);
    logger.debug("spanEvent:{}", spanEvent);
    span.setSpanEventList(Arrays.asList(spanEvent));
    TSpan tSpan = new TSpan();
    TSpanEvent tSpanEvent = new TSpanEvent();
    tSpan.addToSpanEventList(tSpanEvent);
    compressorV1.preProcess(span, tSpan);
    compressorV1.postProcess(span, tSpan);
    Assert.assertEquals("startTime", span.getStartTime() + tSpanEvent.getStartElapsed(), spanEvent.getStartTime());
    Assert.assertEquals("endTime", span.getStartTime() + tSpanEvent.getStartElapsed() + spanEvent.getElapsedTime(), spanEvent.getAfterTime());
}
Also used : DefaultTraceId(com.navercorp.pinpoint.profiler.context.id.DefaultTraceId) DefaultTraceRoot(com.navercorp.pinpoint.profiler.context.id.DefaultTraceRoot) 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) TSpan(com.navercorp.pinpoint.thrift.dto.TSpan) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) Test(org.junit.Test)

Example 7 with DefaultTraceRoot

use of com.navercorp.pinpoint.profiler.context.id.DefaultTraceRoot 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 8 with DefaultTraceRoot

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

the class SpanThriftMessageConverterTest method newSpan.

private Span newSpan() {
    final TraceId traceId = new DefaultTraceId(AGENT_ID, AGENT_START_TIME, 1L);
    final TraceRoot traceRoot = new DefaultTraceRoot(traceId, AGENT_ID, AGENT_START_TIME, 100L);
    return new Span(traceRoot);
}
Also used : DefaultTraceId(com.navercorp.pinpoint.profiler.context.id.DefaultTraceId) DefaultTraceRoot(com.navercorp.pinpoint.profiler.context.id.DefaultTraceRoot) TraceId(com.navercorp.pinpoint.bootstrap.context.TraceId) DefaultTraceId(com.navercorp.pinpoint.profiler.context.id.DefaultTraceId) DefaultTraceRoot(com.navercorp.pinpoint.profiler.context.id.DefaultTraceRoot) TraceRoot(com.navercorp.pinpoint.profiler.context.id.TraceRoot) TSpan(com.navercorp.pinpoint.thrift.dto.TSpan) Span(com.navercorp.pinpoint.profiler.context.Span)

Example 9 with DefaultTraceRoot

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

the class GrpcSpanProcessorV2Test method newSpan.

private Span newSpan() {
    TraceId traceId = new DefaultTraceId("agent", 1, 0);
    TraceRoot traceRoot = new DefaultTraceRoot(traceId, "agent", 0, 3);
    return new Span(traceRoot);
}
Also used : DefaultTraceId(com.navercorp.pinpoint.profiler.context.id.DefaultTraceId) DefaultTraceRoot(com.navercorp.pinpoint.profiler.context.id.DefaultTraceRoot) TraceId(com.navercorp.pinpoint.bootstrap.context.TraceId) DefaultTraceId(com.navercorp.pinpoint.profiler.context.id.DefaultTraceId) DefaultTraceRoot(com.navercorp.pinpoint.profiler.context.id.DefaultTraceRoot) TraceRoot(com.navercorp.pinpoint.profiler.context.id.TraceRoot) PSpan(com.navercorp.pinpoint.grpc.trace.PSpan) Span(com.navercorp.pinpoint.profiler.context.Span)

Aggregations

DefaultTraceId (com.navercorp.pinpoint.profiler.context.id.DefaultTraceId)9 DefaultTraceRoot (com.navercorp.pinpoint.profiler.context.id.DefaultTraceRoot)9 TraceRoot (com.navercorp.pinpoint.profiler.context.id.TraceRoot)9 TraceId (com.navercorp.pinpoint.bootstrap.context.TraceId)8 Test (org.junit.Test)6 Span (com.navercorp.pinpoint.profiler.context.Span)5 DefaultSpanChunk (com.navercorp.pinpoint.profiler.context.DefaultSpanChunk)4 DefaultAsyncSpanChunk (com.navercorp.pinpoint.profiler.context.DefaultAsyncSpanChunk)3 DefaultLocalAsyncId (com.navercorp.pinpoint.profiler.context.DefaultLocalAsyncId)3 SpanChunk (com.navercorp.pinpoint.profiler.context.SpanChunk)3 SpanType (com.navercorp.pinpoint.profiler.context.SpanType)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 PrintStream (java.io.PrintStream)3 SpanRecorder (com.navercorp.pinpoint.bootstrap.context.SpanRecorder)2 Trace (com.navercorp.pinpoint.bootstrap.context.Trace)2 DefaultSpanRecorder (com.navercorp.pinpoint.profiler.context.recorder.DefaultSpanRecorder)2 WrappedSpanEventRecorder (com.navercorp.pinpoint.profiler.context.recorder.WrappedSpanEventRecorder)2 Storage (com.navercorp.pinpoint.profiler.context.storage.Storage)2 TSpan (com.navercorp.pinpoint.thrift.dto.TSpan)2 TSpanEvent (com.navercorp.pinpoint.thrift.dto.TSpanEvent)2