Search in sources :

Example 6 with SpanEvent

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

the class SpanStreamUDPSenderTest method createSpan.

private Span createSpan(int spanEventSize) throws InterruptedException {
    List<SpanEvent> spanEventList = createSpanEventList(spanEventSize);
    Span span = new Span();
    List<TSpanEvent> tSpanEventList = new ArrayList<>();
    for (SpanEvent spanEvent : spanEventList) {
        tSpanEventList.add(spanEvent);
    }
    span.setSpanEventList(tSpanEventList);
    return span;
}
Also used : SpanEvent(com.navercorp.pinpoint.profiler.context.SpanEvent) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) ArrayList(java.util.ArrayList) TSpan(com.navercorp.pinpoint.thrift.dto.TSpan) Span(com.navercorp.pinpoint.profiler.context.Span) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent)

Example 7 with SpanEvent

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

use of com.navercorp.pinpoint.profiler.context.SpanEvent 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 9 with SpanEvent

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

the class SpanProcessorV1 method postProcess.

@Override
public void postProcess(SpanChunk spanChunk, TSpanChunk tSpanChunk) {
    final TraceRoot traceRoot = spanChunk.getTraceRoot();
    final long keyTime = traceRoot.getTraceStartTime();
    final List<SpanEvent> spanEventList = spanChunk.getSpanEventList();
    if (CollectionUtils.isEmpty(spanEventList)) {
        throw new IllegalStateException("SpanChunk.spanEventList is empty");
    }
    final List<TSpanEvent> tSpanEventList = tSpanChunk.getSpanEventList();
    if (CollectionUtils.isEmpty(tSpanEventList)) {
        throw new IllegalStateException("TSpanChunk.spanEventList is empty");
    }
    postEventProcess(spanEventList, tSpanEventList, keyTime);
}
Also used : SpanEvent(com.navercorp.pinpoint.profiler.context.SpanEvent) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) TraceRoot(com.navercorp.pinpoint.profiler.context.id.TraceRoot) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent)

Example 10 with SpanEvent

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

the class OrderedSpanRecorderTest method createAsyncSpanEvent.

private SpanEvent createAsyncSpanEvent(TraceRoot traceRoot, int startElapsed, int sequence) {
    Objects.requireNonNull(traceRoot, "traceRoot");
    if (startElapsed < 0) {
        throw new IllegalArgumentException("startElapsed cannot be less than 0");
    }
    if (sequence < 0) {
        throw new IllegalArgumentException("sequence cannot be less than 0");
    }
    SpanEvent event = new SpanEvent();
    long startTime = traceRoot.getTraceStartTime() + startElapsed;
    event.setStartTime(startTime);
    event.setSequence(sequence);
    return event;
}
Also used : SpanEvent(com.navercorp.pinpoint.profiler.context.SpanEvent)

Aggregations

SpanEvent (com.navercorp.pinpoint.profiler.context.SpanEvent)49 TSpanEvent (com.navercorp.pinpoint.thrift.dto.TSpanEvent)23 Test (org.junit.Test)20 Span (com.navercorp.pinpoint.profiler.context.Span)18 TraceRoot (com.navercorp.pinpoint.profiler.context.id.TraceRoot)10 ArrayList (java.util.ArrayList)10 TSpan (com.navercorp.pinpoint.thrift.dto.TSpan)9 SpanChunk (com.navercorp.pinpoint.profiler.context.SpanChunk)7 PSpanEvent (com.navercorp.pinpoint.grpc.trace.PSpanEvent)6 BasePinpointTest (com.navercorp.pinpoint.test.junit4.BasePinpointTest)6 TraceId (com.navercorp.pinpoint.bootstrap.context.TraceId)5 VisibleForTesting (com.navercorp.pinpoint.common.annotations.VisibleForTesting)5 Shared (com.navercorp.pinpoint.profiler.context.id.Shared)5 DefaultTraceRoot (com.navercorp.pinpoint.profiler.context.id.DefaultTraceRoot)4 TSpanChunk (com.navercorp.pinpoint.thrift.dto.TSpanChunk)4 IntStringValue (com.navercorp.pinpoint.common.util.IntStringValue)3 PSpan (com.navercorp.pinpoint.grpc.trace.PSpan)3 DefaultSpanChunk (com.navercorp.pinpoint.profiler.context.DefaultSpanChunk)3 SpanType (com.navercorp.pinpoint.profiler.context.SpanType)3 DefaultTraceId (com.navercorp.pinpoint.profiler.context.id.DefaultTraceId)3