Search in sources :

Example 1 with PAnnotation

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

the class SpanClientMock method span.

public void span(int count) {
    final int size = 1000;
    final byte[] bytes = new byte[size];
    for (int i = 0; i < size; i++) {
        bytes[i] = (byte) i;
    }
    PAnnotationValue value = PAnnotationValue.newBuilder().setBinaryValue(ByteString.copyFrom(bytes)).build();
    PAnnotation annotation = PAnnotation.newBuilder().setValue(value).build();
    PSpanEvent spanEvent = PSpanEvent.newBuilder().addAnnotation(annotation).build();
    AtomicLong counter = new AtomicLong();
    service.execute(new Runnable() {

        @Override
        public void run() {
            // StreamObserver<PSpanMessage> requestObserver = spanStub.sendSpan(responseObserver);
            try {
                TimeUnit.SECONDS.sleep(3);
            } catch (InterruptedException e) {
            }
            for (int i = 0; i < count; i++) {
                final PSpan span = PSpan.newBuilder().setSpanId(i).addSpanEvent(spanEvent).build();
                final PSpanMessage spanMessage = PSpanMessage.newBuilder().setSpan(span).build();
                spanStream.onNext(spanMessage);
                // requestObserver.onNext(spanMessage);
                try {
                    TimeUnit.MILLISECONDS.sleep(10);
                } catch (InterruptedException e) {
                }
            // System.out.print("S");
            }
            spanStream.onCompleted();
        // requestObserver.onCompleted();
        }
    });
}
Also used : PAnnotationValue(com.navercorp.pinpoint.grpc.trace.PAnnotationValue) AtomicLong(java.util.concurrent.atomic.AtomicLong) PSpanMessage(com.navercorp.pinpoint.grpc.trace.PSpanMessage) PSpan(com.navercorp.pinpoint.grpc.trace.PSpan) PAnnotation(com.navercorp.pinpoint.grpc.trace.PAnnotation) PSpanEvent(com.navercorp.pinpoint.grpc.trace.PSpanEvent)

Example 2 with PAnnotation

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

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

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

the class GrpcSpanBinder method buildAnnotationList.

private List<AnnotationBo> buildAnnotationList(List<PAnnotation> pAnnotationList) {
    if (CollectionUtils.isEmpty(pAnnotationList)) {
        return Collections.emptyList();
    }
    List<AnnotationBo> boList = new ArrayList<>(pAnnotationList.size());
    for (PAnnotation tAnnotation : pAnnotationList) {
        final AnnotationBo annotationBo = newAnnotationBo(tAnnotation);
        boList.add(annotationBo);
    }
    boList.sort(AnnotationComparator.INSTANCE);
    return boList;
}
Also used : AnnotationBo(com.navercorp.pinpoint.common.server.bo.AnnotationBo) PAnnotation(com.navercorp.pinpoint.grpc.trace.PAnnotation) ArrayList(java.util.ArrayList)

Example 5 with PAnnotation

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

the class GrpcSpanMessageConverter method buildPAnnotation.

@VisibleForTesting
List<PAnnotation> buildPAnnotation(List<Annotation<?>> annotations) {
    final List<PAnnotation> tAnnotationList = new ArrayList<>(annotations.size());
    for (Annotation<?> annotation : annotations) {
        final PAnnotation.Builder builder = getAnnotationBuilder();
        builder.setKey(annotation.getKey());
        final PAnnotationValue pAnnotationValue = grpcAnnotationValueMapper.buildPAnnotationValue(annotation);
        if (pAnnotationValue != null) {
            builder.setValue(pAnnotationValue);
        }
        PAnnotation pAnnotation = builder.build();
        tAnnotationList.add(pAnnotation);
    }
    return tAnnotationList;
}
Also used : PAnnotationValue(com.navercorp.pinpoint.grpc.trace.PAnnotationValue) PAnnotation(com.navercorp.pinpoint.grpc.trace.PAnnotation) ArrayList(java.util.ArrayList) VisibleForTesting(com.navercorp.pinpoint.common.annotations.VisibleForTesting)

Aggregations

PAnnotation (com.navercorp.pinpoint.grpc.trace.PAnnotation)6 VisibleForTesting (com.navercorp.pinpoint.common.annotations.VisibleForTesting)3 PSpanEvent (com.navercorp.pinpoint.grpc.trace.PSpanEvent)3 IntStringValue (com.navercorp.pinpoint.common.util.IntStringValue)2 PAnnotationValue (com.navercorp.pinpoint.grpc.trace.PAnnotationValue)2 PIntStringValue (com.navercorp.pinpoint.grpc.trace.PIntStringValue)2 PSpan (com.navercorp.pinpoint.grpc.trace.PSpan)2 Annotation (com.navercorp.pinpoint.profiler.context.Annotation)2 ArrayList (java.util.ArrayList)2 TraceId (com.navercorp.pinpoint.bootstrap.context.TraceId)1 AnnotationBo (com.navercorp.pinpoint.common.server.bo.AnnotationBo)1 AnnotationFactory (com.navercorp.pinpoint.common.server.bo.AnnotationFactory)1 PAcceptEvent (com.navercorp.pinpoint.grpc.trace.PAcceptEvent)1 PLocalAsyncId (com.navercorp.pinpoint.grpc.trace.PLocalAsyncId)1 PNextEvent (com.navercorp.pinpoint.grpc.trace.PNextEvent)1 PSpanMessage (com.navercorp.pinpoint.grpc.trace.PSpanMessage)1 PTransactionId (com.navercorp.pinpoint.grpc.trace.PTransactionId)1 AsyncId (com.navercorp.pinpoint.profiler.context.AsyncId)1 LocalAsyncId (com.navercorp.pinpoint.profiler.context.LocalAsyncId)1 SpanEvent (com.navercorp.pinpoint.profiler.context.SpanEvent)1