Search in sources :

Example 1 with PSpanEvent

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

the class GrpcSpanHandler method createSimpleSpanLog.

private String createSimpleSpanLog(PSpan span) {
    if (!isDebug) {
        return "";
    }
    StringBuilder log = new StringBuilder();
    PTransactionId transactionId = span.getTransactionId();
    log.append(" transactionId:");
    log.append(MessageFormatUtils.debugLog(transactionId));
    log.append(" spanId:").append(span.getSpanId());
    StringBuilder spanEventSequenceLog = new StringBuilder();
    List<PSpanEvent> spanEventList = span.getSpanEventList();
    for (PSpanEvent pSpanEvent : spanEventList) {
        if (pSpanEvent == null) {
            continue;
        }
        spanEventSequenceLog.append(pSpanEvent.getSequence()).append(" ");
    }
    log.append(" spanEventSequence:").append(spanEventSequenceLog.toString());
    return log.toString();
}
Also used : PTransactionId(com.navercorp.pinpoint.grpc.trace.PTransactionId) PSpanEvent(com.navercorp.pinpoint.grpc.trace.PSpanEvent)

Example 2 with PSpanEvent

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

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

the class CollectorGrpcSpanFactoryTest method newSpanChunk_overflow.

private PSpanChunk newSpanChunk_overflow() {
    PSpanEvent sequenceOverflowEvent = newEvent(MAX_SEQUENCE + 1, 1);
    PSpanEvent event = newEvent(MAX_SEQUENCE + 2, 0);
    return newSpanChunk(sequenceOverflowEvent, event);
}
Also used : PSpanEvent(com.navercorp.pinpoint.grpc.trace.PSpanEvent)

Example 4 with PSpanEvent

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

the class CollectorGrpcSpanFactoryTest method newSpanChunk_compact_depth_error.

private PSpanChunk newSpanChunk_compact_depth_error() {
    PSpanEvent sequenceOverflowEvent = newEvent(MAX_SEQUENCE + 1, 1);
    PSpanEvent event = newEvent(1, 0);
    return newSpanChunk(sequenceOverflowEvent, event);
}
Also used : PSpanEvent(com.navercorp.pinpoint.grpc.trace.PSpanEvent)

Example 5 with PSpanEvent

use of com.navercorp.pinpoint.grpc.trace.PSpanEvent 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)

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