Search in sources :

Example 1 with PSpanChunk

use of com.navercorp.pinpoint.grpc.trace.PSpanChunk in project pinpoint by naver.

the class CollectorGrpcSpanFactoryTest method buildSpanChunkBo_first_depth_zero.

@Test
public void buildSpanChunkBo_first_depth_zero() {
    final PSpanChunk chunk = newSpanChunk_first_depth_zero();
    final Header header = newHeader();
    SpanChunkBo spanChunkBo = factory.buildSpanChunkBo(chunk, header);
    List<SpanEventBo> spanEventBoList = spanChunkBo.getSpanEventBoList();
    SpanEventBo spanEventBo0 = spanEventBoList.get(0);
    SpanEventBo spanEventBo1 = spanEventBoList.get(1);
    Assert.assertEquals(0, spanEventBo0.getDepth());
    Assert.assertEquals(1, spanEventBo1.getDepth());
}
Also used : Header(com.navercorp.pinpoint.grpc.Header) SpanChunkBo(com.navercorp.pinpoint.common.server.bo.SpanChunkBo) PSpanChunk(com.navercorp.pinpoint.grpc.trace.PSpanChunk) SpanEventBo(com.navercorp.pinpoint.common.server.bo.SpanEventBo) Test(org.junit.Test)

Example 2 with PSpanChunk

use of com.navercorp.pinpoint.grpc.trace.PSpanChunk in project pinpoint by naver.

the class CollectorGrpcSpanFactoryTest method buildSpanChunkBo_compact_depth_NPE.

@Test
public void buildSpanChunkBo_compact_depth_NPE() {
    final PSpanChunk chunk = newSpanChunk_compact_depth_error();
    final Header header = newHeader();
    SpanChunkBo spanChunkBo = factory.buildSpanChunkBo(chunk, header);
    List<SpanEventBo> spanEventBoList = spanChunkBo.getSpanEventBoList();
    SpanEventBo spanEventBo0 = spanEventBoList.get(0);
    Assert.assertEquals(1, spanEventBo0.getDepth());
}
Also used : Header(com.navercorp.pinpoint.grpc.Header) SpanChunkBo(com.navercorp.pinpoint.common.server.bo.SpanChunkBo) PSpanChunk(com.navercorp.pinpoint.grpc.trace.PSpanChunk) SpanEventBo(com.navercorp.pinpoint.common.server.bo.SpanEventBo) Test(org.junit.Test)

Example 3 with PSpanChunk

use of com.navercorp.pinpoint.grpc.trace.PSpanChunk in project pinpoint by naver.

the class GrpcSpanMessageConverter method buildPSpanChunk.

@VisibleForTesting
PSpanChunk buildPSpanChunk(SpanChunk spanChunk) {
    final PSpanChunk.Builder pSpanChunk = PSpanChunk.newBuilder();
    pSpanChunk.setVersion(SpanVersion.TRACE_V2);
    // tSpanChunk.setApplicationName(applicationName);
    // tSpanChunk.setAgentId(agentId);
    // tSpanChunk.setAgentStartTime(agentStartTime);
    pSpanChunk.setApplicationServiceType(applicationServiceType);
    final TraceRoot traceRoot = spanChunk.getTraceRoot();
    final TraceId traceId = traceRoot.getTraceId();
    final PTransactionId transactionId = newTransactionId(traceId);
    pSpanChunk.setTransactionId(transactionId);
    pSpanChunk.setSpanId(traceId.getSpanId());
    final Shared shared = traceRoot.getShared();
    final String endPoint = shared.getEndPoint();
    if (endPoint != null) {
        pSpanChunk.setEndPoint(endPoint);
    }
    if (spanChunk instanceof AsyncSpanChunk) {
        final AsyncSpanChunk asyncSpanChunk = (AsyncSpanChunk) spanChunk;
        final LocalAsyncId localAsyncId = asyncSpanChunk.getLocalAsyncId();
        final PLocalAsyncId.Builder pAsyncIdBuilder = PLocalAsyncId.newBuilder();
        pAsyncIdBuilder.setAsyncId(localAsyncId.getAsyncId());
        pAsyncIdBuilder.setSequence(localAsyncId.getSequence());
        final PLocalAsyncId pLocalAsyncId = pAsyncIdBuilder.build();
        pSpanChunk.setLocalAsyncId(pLocalAsyncId);
    }
    this.spanProcessor.preProcess(spanChunk, pSpanChunk);
    final List<SpanEvent> spanEventList = spanChunk.getSpanEventList();
    if (CollectionUtils.hasLength(spanEventList)) {
        final List<PSpanEvent> pSpanEvents = buildPSpanEventList(spanEventList);
        pSpanChunk.addAllSpanEvent(pSpanEvents);
    }
    this.spanProcessor.postProcess(spanChunk, pSpanChunk);
    return pSpanChunk.build();
}
Also used : PLocalAsyncId(com.navercorp.pinpoint.grpc.trace.PLocalAsyncId) LocalAsyncId(com.navercorp.pinpoint.profiler.context.LocalAsyncId) PLocalAsyncId(com.navercorp.pinpoint.grpc.trace.PLocalAsyncId) PSpanChunk(com.navercorp.pinpoint.grpc.trace.PSpanChunk) PTransactionId(com.navercorp.pinpoint.grpc.trace.PTransactionId) Shared(com.navercorp.pinpoint.profiler.context.id.Shared) AsyncSpanChunk(com.navercorp.pinpoint.profiler.context.AsyncSpanChunk) PSpanEvent(com.navercorp.pinpoint.grpc.trace.PSpanEvent) SpanEvent(com.navercorp.pinpoint.profiler.context.SpanEvent) TraceId(com.navercorp.pinpoint.bootstrap.context.TraceId) TraceRoot(com.navercorp.pinpoint.profiler.context.id.TraceRoot) PSpanEvent(com.navercorp.pinpoint.grpc.trace.PSpanEvent) VisibleForTesting(com.navercorp.pinpoint.common.annotations.VisibleForTesting)

Example 4 with PSpanChunk

use of com.navercorp.pinpoint.grpc.trace.PSpanChunk 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 5 with PSpanChunk

use of com.navercorp.pinpoint.grpc.trace.PSpanChunk in project pinpoint by naver.

the class CollectorGrpcSpanFactoryTest method buildSpanChunkBo_sequence_overflow_NPE.

@Test
public void buildSpanChunkBo_sequence_overflow_NPE() {
    final PSpanChunk chunk = newSpanChunk_overflow();
    final Header header = newHeader();
    SpanChunkBo spanChunkBo = factory.buildSpanChunkBo(chunk, header);
    List<SpanEventBo> spanEventBoList = spanChunkBo.getSpanEventBoList();
    Assert.assertTrue(spanEventBoList.isEmpty());
}
Also used : Header(com.navercorp.pinpoint.grpc.Header) SpanChunkBo(com.navercorp.pinpoint.common.server.bo.SpanChunkBo) PSpanChunk(com.navercorp.pinpoint.grpc.trace.PSpanChunk) SpanEventBo(com.navercorp.pinpoint.common.server.bo.SpanEventBo) Test(org.junit.Test)

Aggregations

PSpanChunk (com.navercorp.pinpoint.grpc.trace.PSpanChunk)6 SpanChunkBo (com.navercorp.pinpoint.common.server.bo.SpanChunkBo)4 SpanEventBo (com.navercorp.pinpoint.common.server.bo.SpanEventBo)4 Header (com.navercorp.pinpoint.grpc.Header)4 Test (org.junit.Test)4 AsyncSpanChunk (com.navercorp.pinpoint.profiler.context.AsyncSpanChunk)2 TraceId (com.navercorp.pinpoint.bootstrap.context.TraceId)1 VisibleForTesting (com.navercorp.pinpoint.common.annotations.VisibleForTesting)1 PLocalAsyncId (com.navercorp.pinpoint.grpc.trace.PLocalAsyncId)1 PSpan (com.navercorp.pinpoint.grpc.trace.PSpan)1 PSpanEvent (com.navercorp.pinpoint.grpc.trace.PSpanEvent)1 PTransactionId (com.navercorp.pinpoint.grpc.trace.PTransactionId)1 LocalAsyncId (com.navercorp.pinpoint.profiler.context.LocalAsyncId)1 Span (com.navercorp.pinpoint.profiler.context.Span)1 SpanChunk (com.navercorp.pinpoint.profiler.context.SpanChunk)1 SpanEvent (com.navercorp.pinpoint.profiler.context.SpanEvent)1 Shared (com.navercorp.pinpoint.profiler.context.id.Shared)1 TraceRoot (com.navercorp.pinpoint.profiler.context.id.TraceRoot)1