Search in sources :

Example 6 with PSpanEvent

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

the class GrpcSpanMessageConverter method buildPSpanEvent.

@VisibleForTesting
public PSpanEvent.Builder buildPSpanEvent(SpanEvent spanEvent) {
    final PSpanEvent.Builder pSpanEvent = getSpanEventBuilder();
    // tSpanEvent.setStartElapsed(spanEvent.getStartElapsed());
    if (spanEvent.getElapsedTime() != 0) {
        pSpanEvent.setEndElapsed(spanEvent.getElapsedTime());
    }
    pSpanEvent.setSequence(spanEvent.getSequence());
    // tSpanEvent.setRpc(spanEvent.getRpc());
    pSpanEvent.setServiceType(spanEvent.getServiceType());
    // tSpanEvent.setAnnotations();
    if (spanEvent.getDepth() != -1) {
        pSpanEvent.setDepth(spanEvent.getDepth());
    }
    pSpanEvent.setApiId(spanEvent.getApiId());
    final IntStringValue exceptionInfo = spanEvent.getExceptionInfo();
    if (exceptionInfo != null) {
        PIntStringValue pIntStringValue = buildPIntStringValue(exceptionInfo);
        pSpanEvent.setExceptionInfo(pIntStringValue);
    }
    final PNextEvent nextEvent = buildNextEvent(spanEvent);
    if (nextEvent != null) {
        pSpanEvent.setNextEvent(nextEvent);
    }
    final AsyncId asyncIdObject = spanEvent.getAsyncIdObject();
    if (asyncIdObject != null) {
        pSpanEvent.setAsyncEvent(asyncIdObject.getAsyncId());
    }
    final List<Annotation<?>> annotations = spanEvent.getAnnotations();
    if (CollectionUtils.hasLength(annotations)) {
        final List<PAnnotation> pAnnotations = buildPAnnotation(annotations);
        pSpanEvent.addAllAnnotation(pAnnotations);
    }
    return pSpanEvent;
}
Also used : PNextEvent(com.navercorp.pinpoint.grpc.trace.PNextEvent) PIntStringValue(com.navercorp.pinpoint.grpc.trace.PIntStringValue) PAnnotation(com.navercorp.pinpoint.grpc.trace.PAnnotation) IntStringValue(com.navercorp.pinpoint.common.util.IntStringValue) PIntStringValue(com.navercorp.pinpoint.grpc.trace.PIntStringValue) PLocalAsyncId(com.navercorp.pinpoint.grpc.trace.PLocalAsyncId) AsyncId(com.navercorp.pinpoint.profiler.context.AsyncId) LocalAsyncId(com.navercorp.pinpoint.profiler.context.LocalAsyncId) PSpanEvent(com.navercorp.pinpoint.grpc.trace.PSpanEvent) Annotation(com.navercorp.pinpoint.profiler.context.Annotation) PAnnotation(com.navercorp.pinpoint.grpc.trace.PAnnotation) VisibleForTesting(com.navercorp.pinpoint.common.annotations.VisibleForTesting)

Example 7 with PSpanEvent

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

the class GrpcSpanMessageConverter method buildPSpan.

@VisibleForTesting
PSpan buildPSpan(Span span) {
    final PSpan.Builder pSpan = PSpan.newBuilder();
    pSpan.setVersion(SpanVersion.TRACE_V2);
    pSpan.setApplicationServiceType(applicationServiceType);
    final TraceRoot traceRoot = span.getTraceRoot();
    final TraceId traceId = traceRoot.getTraceId();
    final PTransactionId transactionId = newTransactionId(traceId);
    pSpan.setTransactionId(transactionId);
    pSpan.setSpanId(traceId.getSpanId());
    pSpan.setParentSpanId(traceId.getParentSpanId());
    pSpan.setStartTime(span.getStartTime());
    pSpan.setElapsed(span.getElapsedTime());
    pSpan.setServiceType(span.getServiceType());
    PAcceptEvent pAcceptEvent = newAcceptEvent(span);
    pSpan.setAcceptEvent(pAcceptEvent);
    pSpan.setFlag(traceId.getFlags());
    Shared shared = span.getTraceRoot().getShared();
    pSpan.setErr(shared.getErrorCode());
    pSpan.setApiId(span.getApiId());
    final IntStringValue exceptionInfo = span.getExceptionInfo();
    if (exceptionInfo != null) {
        PIntStringValue pIntStringValue = buildPIntStringValue(exceptionInfo);
        pSpan.setExceptionInfo(pIntStringValue);
    }
    pSpan.setLoggingTransactionInfo(shared.getLoggingInfo());
    final List<Annotation<?>> annotations = span.getAnnotations();
    if (CollectionUtils.hasLength(annotations)) {
        final List<PAnnotation> tAnnotations = buildPAnnotation(annotations);
        pSpan.addAllAnnotation(tAnnotations);
    }
    this.spanProcessor.preProcess(span, pSpan);
    final List<SpanEvent> spanEventList = span.getSpanEventList();
    if (CollectionUtils.hasLength(spanEventList)) {
        final List<PSpanEvent> pSpanEvents = buildPSpanEventList(spanEventList);
        pSpan.addAllSpanEvent(pSpanEvents);
    }
    this.spanProcessor.postProcess(span, pSpan);
    return pSpan.build();
}
Also used : PAnnotation(com.navercorp.pinpoint.grpc.trace.PAnnotation) PTransactionId(com.navercorp.pinpoint.grpc.trace.PTransactionId) Shared(com.navercorp.pinpoint.profiler.context.id.Shared) Annotation(com.navercorp.pinpoint.profiler.context.Annotation) PAnnotation(com.navercorp.pinpoint.grpc.trace.PAnnotation) PSpan(com.navercorp.pinpoint.grpc.trace.PSpan) PIntStringValue(com.navercorp.pinpoint.grpc.trace.PIntStringValue) IntStringValue(com.navercorp.pinpoint.common.util.IntStringValue) PIntStringValue(com.navercorp.pinpoint.grpc.trace.PIntStringValue) 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) PAcceptEvent(com.navercorp.pinpoint.grpc.trace.PAcceptEvent) PSpanEvent(com.navercorp.pinpoint.grpc.trace.PSpanEvent) VisibleForTesting(com.navercorp.pinpoint.common.annotations.VisibleForTesting)

Example 8 with PSpanEvent

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

the class GrpcSpanProcessorV2Test method postProcess.

@Test
public void postProcess() {
    Span span = newSpan();
    SpanEventBuilder factory = new SpanEventBuilder();
    factory.addSpanEvent();
    factory.addSpanEvent();
    factory.addSpanEvent();
    span.setSpanEventList(factory.getSpanEventList());
    PSpan.Builder builder = PSpan.newBuilder();
    for (SpanEvent spanEvent : span.getSpanEventList()) {
        PSpanEvent.Builder pSpanEvent = converter.buildPSpanEvent(spanEvent);
        builder.addSpanEvent(pSpanEvent);
    }
    spanProcessorProtoV2.postProcess(span, builder);
    PSpan pSpan = builder.build();
    List<PSpanEvent> pSpanEventList = pSpan.getSpanEventList();
    List<SpanEvent> spanEventList = span.getSpanEventList();
    long keyStartTime = span.getStartTime();
    for (int i = 0; i < pSpanEventList.size(); i++) {
        PSpanEvent pSpanEvent = pSpanEventList.get(i);
        SpanEvent next = spanEventList.get(i);
        long startTime = keyStartTime + pSpanEvent.getStartElapsed();
        Assert.assertEquals(startTime, next.getStartTime());
        keyStartTime = startTime;
    }
}
Also used : PSpan(com.navercorp.pinpoint.grpc.trace.PSpan) PSpanEvent(com.navercorp.pinpoint.grpc.trace.PSpanEvent) SpanEvent(com.navercorp.pinpoint.profiler.context.SpanEvent) PSpanEvent(com.navercorp.pinpoint.grpc.trace.PSpanEvent) PSpan(com.navercorp.pinpoint.grpc.trace.PSpan) Span(com.navercorp.pinpoint.profiler.context.Span) Test(org.junit.Test)

Example 9 with PSpanEvent

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

the class CollectorGrpcSpanFactory method buildSpanChunkBo.

@Override
public SpanChunkBo buildSpanChunkBo(PSpanChunk pSpanChunk, Header header) {
    final SpanChunkBo spanChunkBo = this.grpcBinder.bindSpanChunkBo(pSpanChunk, header);
    final long acceptedTime = acceptedTimeService.getAcceptedTime();
    spanChunkBo.setCollectorAcceptTime(acceptedTime);
    final List<PSpanEvent> pSpanEventList = pSpanChunk.getSpanEventList();
    List<SpanEventBo> spanEventList = buildSpanEventBoList(pSpanEventList);
    spanChunkBo.addSpanEventBoList(spanEventList);
    return spanChunkBo;
}
Also used : SpanChunkBo(com.navercorp.pinpoint.common.server.bo.SpanChunkBo) PSpanEvent(com.navercorp.pinpoint.grpc.trace.PSpanEvent) SpanEventBo(com.navercorp.pinpoint.common.server.bo.SpanEventBo)

Example 10 with PSpanEvent

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

the class GrpcSpanBinder method bindSpanEventBoList.

public List<SpanEventBo> bindSpanEventBoList(List<PSpanEvent> spanEventList) {
    if (CollectionUtils.isEmpty(spanEventList)) {
        return Collections.emptyList();
    }
    List<SpanEventBo> spanEventBoList = new ArrayList<>(spanEventList.size());
    SpanEventBo prevSpanEvent = null;
    for (PSpanEvent pSpanEvent : spanEventList) {
        final SpanEventBo spanEventBo = buildSpanEventBo(pSpanEvent, prevSpanEvent);
        spanEventBoList.add(spanEventBo);
        prevSpanEvent = spanEventBo;
    }
    spanEventBoList.sort(SpanEventComparator.INSTANCE);
    return spanEventBoList;
}
Also used : ArrayList(java.util.ArrayList) PSpanEvent(com.navercorp.pinpoint.grpc.trace.PSpanEvent) SpanEventBo(com.navercorp.pinpoint.common.server.bo.SpanEventBo)

Aggregations

PSpanEvent (com.navercorp.pinpoint.grpc.trace.PSpanEvent)17 SpanEvent (com.navercorp.pinpoint.profiler.context.SpanEvent)5 PTransactionId (com.navercorp.pinpoint.grpc.trace.PTransactionId)4 VisibleForTesting (com.navercorp.pinpoint.common.annotations.VisibleForTesting)3 SpanEventBo (com.navercorp.pinpoint.common.server.bo.SpanEventBo)3 PAnnotation (com.navercorp.pinpoint.grpc.trace.PAnnotation)3 PSpan (com.navercorp.pinpoint.grpc.trace.PSpan)3 TraceId (com.navercorp.pinpoint.bootstrap.context.TraceId)2 IntStringValue (com.navercorp.pinpoint.common.util.IntStringValue)2 PIntStringValue (com.navercorp.pinpoint.grpc.trace.PIntStringValue)2 PLocalAsyncId (com.navercorp.pinpoint.grpc.trace.PLocalAsyncId)2 Annotation (com.navercorp.pinpoint.profiler.context.Annotation)2 LocalAsyncId (com.navercorp.pinpoint.profiler.context.LocalAsyncId)2 Shared (com.navercorp.pinpoint.profiler.context.id.Shared)2 TraceRoot (com.navercorp.pinpoint.profiler.context.id.TraceRoot)2 ArrayList (java.util.ArrayList)2 SpanBo (com.navercorp.pinpoint.common.server.bo.SpanBo)1 SpanChunkBo (com.navercorp.pinpoint.common.server.bo.SpanChunkBo)1 PAcceptEvent (com.navercorp.pinpoint.grpc.trace.PAcceptEvent)1 PAnnotationValue (com.navercorp.pinpoint.grpc.trace.PAnnotationValue)1