Search in sources :

Example 1 with PTransactionId

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

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

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

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

the class GrpcSpanChunkHandler method createSimpleSpanChunkLog.

private String createSimpleSpanChunkLog(PSpanChunk spanChunk) {
    if (!isDebug) {
        return "";
    }
    StringBuilder log = new StringBuilder();
    PTransactionId transactionId = spanChunk.getTransactionId();
    log.append(" transactionId:");
    log.append(MessageFormatUtils.debugLog(transactionId));
    log.append(" spanId:").append(spanChunk.getSpanId());
    StringBuilder spanEventSequenceLog = new StringBuilder();
    List<PSpanEvent> spanEventList = spanChunk.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 5 with PTransactionId

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

the class GrpcSpanBinder method newSpanChunkBo.

// for test
SpanChunkBo newSpanChunkBo(PSpanChunk pSpanChunk, Header header) {
    final SpanChunkBo spanChunkBo = new SpanChunkBo();
    spanChunkBo.setVersion(pSpanChunk.getVersion());
    spanChunkBo.setAgentId(header.getAgentId());
    spanChunkBo.setApplicationId(header.getApplicationName());
    spanChunkBo.setAgentStartTime(header.getAgentStartTime());
    spanChunkBo.setApplicationServiceType((short) pSpanChunk.getApplicationServiceType());
    if (pSpanChunk.hasTransactionId()) {
        PTransactionId pTransactionId = pSpanChunk.getTransactionId();
        TransactionId transactionId = newTransactionId(pTransactionId, spanChunkBo.getAgentId());
        spanChunkBo.setTransactionId(transactionId);
    } else {
        logger.warn("PTransactionId is not set {}", pSpanChunk);
        throw new IllegalStateException("PTransactionId is not set");
    }
    spanChunkBo.setKeyTime(pSpanChunk.getKeyTime());
    spanChunkBo.setSpanId(pSpanChunk.getSpanId());
    spanChunkBo.setEndPoint(pSpanChunk.getEndPoint());
    return spanChunkBo;
}
Also used : SpanChunkBo(com.navercorp.pinpoint.common.server.bo.SpanChunkBo) PTransactionId(com.navercorp.pinpoint.grpc.trace.PTransactionId) PTransactionId(com.navercorp.pinpoint.grpc.trace.PTransactionId) TransactionId(com.navercorp.pinpoint.common.profiler.util.TransactionId)

Aggregations

PTransactionId (com.navercorp.pinpoint.grpc.trace.PTransactionId)5 PSpanEvent (com.navercorp.pinpoint.grpc.trace.PSpanEvent)4 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 TransactionId (com.navercorp.pinpoint.common.profiler.util.TransactionId)1 SpanChunkBo (com.navercorp.pinpoint.common.server.bo.SpanChunkBo)1 IntStringValue (com.navercorp.pinpoint.common.util.IntStringValue)1 PAcceptEvent (com.navercorp.pinpoint.grpc.trace.PAcceptEvent)1 PAnnotation (com.navercorp.pinpoint.grpc.trace.PAnnotation)1 PIntStringValue (com.navercorp.pinpoint.grpc.trace.PIntStringValue)1 PLocalAsyncId (com.navercorp.pinpoint.grpc.trace.PLocalAsyncId)1 PSpan (com.navercorp.pinpoint.grpc.trace.PSpan)1 PSpanChunk (com.navercorp.pinpoint.grpc.trace.PSpanChunk)1 Annotation (com.navercorp.pinpoint.profiler.context.Annotation)1 AsyncSpanChunk (com.navercorp.pinpoint.profiler.context.AsyncSpanChunk)1 LocalAsyncId (com.navercorp.pinpoint.profiler.context.LocalAsyncId)1