Search in sources :

Example 1 with LocalAsyncId

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

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

the class SpanThriftMessageConverter method buildTSpanChunk.

@VisibleForTesting
TSpanChunk buildTSpanChunk(SpanChunk spanChunk) {
    final TSpanChunk tSpanChunk = new TSpanChunk();
    tSpanChunk.setApplicationName(applicationName);
    tSpanChunk.setAgentId(agentId);
    tSpanChunk.setAgentStartTime(agentStartTime);
    tSpanChunk.setApplicationServiceType(applicationServiceType);
    final TraceRoot traceRoot = spanChunk.getTraceRoot();
    final TraceId traceId = traceRoot.getTraceId();
    final ByteBuffer transactionId = transactionIdEncoder.encodeTransactionId(traceId);
    tSpanChunk.setTransactionId(transactionId);
    tSpanChunk.setSpanId(traceId.getSpanId());
    final Shared shared = traceRoot.getShared();
    tSpanChunk.setEndPoint(shared.getEndPoint());
    if (spanChunk instanceof AsyncSpanChunk) {
        final AsyncSpanChunk asyncSpanChunk = (AsyncSpanChunk) spanChunk;
        final LocalAsyncId localAsyncId = asyncSpanChunk.getLocalAsyncId();
        final TLocalAsyncId tLocalAsyncId = new TLocalAsyncId(localAsyncId.getAsyncId(), localAsyncId.getSequence());
        tSpanChunk.setLocalAsyncId(tLocalAsyncId);
    }
    spanPostProcessor.preProcess(spanChunk, tSpanChunk);
    final List<SpanEvent> spanEventList = spanChunk.getSpanEventList();
    if (CollectionUtils.hasLength(spanEventList)) {
        final List<TSpanEvent> tSpanEvents = buildTSpanEventList(spanEventList);
        tSpanChunk.setSpanEventList(tSpanEvents);
    }
    spanPostProcessor.postProcess(spanChunk, tSpanChunk);
    return tSpanChunk;
}
Also used : TSpanChunk(com.navercorp.pinpoint.thrift.dto.TSpanChunk) AsyncSpanChunk(com.navercorp.pinpoint.profiler.context.AsyncSpanChunk) TLocalAsyncId(com.navercorp.pinpoint.thrift.dto.TLocalAsyncId) LocalAsyncId(com.navercorp.pinpoint.profiler.context.LocalAsyncId) TLocalAsyncId(com.navercorp.pinpoint.thrift.dto.TLocalAsyncId) SpanEvent(com.navercorp.pinpoint.profiler.context.SpanEvent) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) TraceId(com.navercorp.pinpoint.bootstrap.context.TraceId) TraceRoot(com.navercorp.pinpoint.profiler.context.id.TraceRoot) Shared(com.navercorp.pinpoint.profiler.context.id.Shared) ByteBuffer(java.nio.ByteBuffer) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) VisibleForTesting(com.navercorp.pinpoint.common.annotations.VisibleForTesting)

Example 3 with LocalAsyncId

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

the class SpanEventFacade method getAsyncId.

@Override
public Integer getAsyncId() {
    if (!(spanChunk instanceof AsyncSpanChunk)) {
        return null;
    }
    AsyncSpanChunk asyncSpanChunk = (AsyncSpanChunk) this.spanChunk;
    LocalAsyncId localAsyncId = asyncSpanChunk.getLocalAsyncId();
    return localAsyncId.getAsyncId();
}
Also used : AsyncSpanChunk(com.navercorp.pinpoint.profiler.context.AsyncSpanChunk) LocalAsyncId(com.navercorp.pinpoint.profiler.context.LocalAsyncId)

Example 4 with LocalAsyncId

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

the class Item method compareAsyncItems.

private static <T> int compareAsyncItems(Item<T> lhs, Item<T> rhs) {
    final LocalAsyncId localAsyncId1 = lhs.localAsyncId;
    final LocalAsyncId localAsyncId2 = rhs.localAsyncId;
    if (localAsyncId1.getAsyncId() < localAsyncId2.getAsyncId()) {
        return -1;
    } else if (localAsyncId1.getAsyncId() > localAsyncId2.getAsyncId()) {
        return 1;
    } else {
        if (localAsyncId1.getSequence() < localAsyncId2.getSequence()) {
            return -1;
        } else if (localAsyncId1.getSequence() > localAsyncId2.getSequence()) {
            return 1;
        } else {
            if (lhs.sequence < rhs.sequence) {
                return -1;
            } else if (lhs.sequence > rhs.sequence) {
                return 1;
            } else {
                return compareHashes(lhs, rhs);
            }
        }
    }
}
Also used : LocalAsyncId(com.navercorp.pinpoint.profiler.context.LocalAsyncId)

Aggregations

LocalAsyncId (com.navercorp.pinpoint.profiler.context.LocalAsyncId)4 AsyncSpanChunk (com.navercorp.pinpoint.profiler.context.AsyncSpanChunk)3 TraceId (com.navercorp.pinpoint.bootstrap.context.TraceId)2 VisibleForTesting (com.navercorp.pinpoint.common.annotations.VisibleForTesting)2 SpanEvent (com.navercorp.pinpoint.profiler.context.SpanEvent)2 Shared (com.navercorp.pinpoint.profiler.context.id.Shared)2 TraceRoot (com.navercorp.pinpoint.profiler.context.id.TraceRoot)2 PLocalAsyncId (com.navercorp.pinpoint.grpc.trace.PLocalAsyncId)1 PSpanChunk (com.navercorp.pinpoint.grpc.trace.PSpanChunk)1 PSpanEvent (com.navercorp.pinpoint.grpc.trace.PSpanEvent)1 PTransactionId (com.navercorp.pinpoint.grpc.trace.PTransactionId)1 TLocalAsyncId (com.navercorp.pinpoint.thrift.dto.TLocalAsyncId)1 TSpanChunk (com.navercorp.pinpoint.thrift.dto.TSpanChunk)1 TSpanEvent (com.navercorp.pinpoint.thrift.dto.TSpanEvent)1 ByteBuffer (java.nio.ByteBuffer)1