Search in sources :

Example 1 with PAcceptEvent

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

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

the class GrpcSpanMessageConverter method newAcceptEvent.

private PAcceptEvent newAcceptEvent(Span span) {
    PAcceptEvent.Builder builder = PAcceptEvent.newBuilder();
    builder.setRemoteAddr(span.getRemoteAddr());
    final Shared shared = span.getTraceRoot().getShared();
    builder.setRpc(shared.getRpcName());
    builder.setEndPoint(shared.getEndPoint());
    PParentInfo pParentInfo = newParentInfo(span);
    if (pParentInfo != null) {
        builder.setParentInfo(pParentInfo);
    }
    return builder.build();
}
Also used : PParentInfo(com.navercorp.pinpoint.grpc.trace.PParentInfo) PAcceptEvent(com.navercorp.pinpoint.grpc.trace.PAcceptEvent) Shared(com.navercorp.pinpoint.profiler.context.id.Shared)

Example 3 with PAcceptEvent

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

the class GrpcSpanBinder method newSpanBo.

// for test
SpanBo newSpanBo(PSpan pSpan, Header header) {
    final SpanBo spanBo = new SpanBo();
    spanBo.setVersion(pSpan.getVersion());
    spanBo.setAgentId(header.getAgentId());
    spanBo.setApplicationId(header.getApplicationName());
    spanBo.setAgentStartTime(header.getAgentStartTime());
    if (!pSpan.hasTransactionId()) {
        throw new IllegalStateException("hasTransactionId() is false " + MessageFormatUtils.debugLog(pSpan));
    }
    final TransactionId transactionId = newTransactionId(pSpan.getTransactionId(), spanBo.getAgentId());
    spanBo.setTransactionId(transactionId);
    spanBo.setSpanId(pSpan.getSpanId());
    spanBo.setParentSpanId(pSpan.getParentSpanId());
    spanBo.setStartTime(pSpan.getStartTime());
    spanBo.setElapsed(pSpan.getElapsed());
    spanBo.setServiceType((short) pSpan.getServiceType());
    spanBo.setFlag((short) pSpan.getFlag());
    spanBo.setApiId(pSpan.getApiId());
    spanBo.setErrCode(pSpan.getErr());
    spanBo.setLoggingTransactionInfo((byte) pSpan.getLoggingTransactionInfo());
    spanBo.setApplicationServiceType((short) pSpan.getApplicationServiceType());
    if (pSpan.hasAcceptEvent()) {
        final PAcceptEvent acceptEvent = pSpan.getAcceptEvent();
        final String rpc = acceptEvent.getRpc();
        if (StringUtils.hasLength(rpc)) {
            spanBo.setRpc(rpc);
        }
        final String remoteAddr = acceptEvent.getRemoteAddr();
        if (StringUtils.hasLength(remoteAddr)) {
            spanBo.setRemoteAddr(remoteAddr);
        }
        final String endPoint = acceptEvent.getEndPoint();
        if (StringUtils.hasLength(endPoint)) {
            spanBo.setEndPoint(endPoint);
        }
        if (acceptEvent.hasParentInfo()) {
            final PParentInfo parentInfo = acceptEvent.getParentInfo();
            final String acceptorHost = parentInfo.getAcceptorHost();
            if (StringUtils.hasLength(acceptorHost)) {
                spanBo.setAcceptorHost(acceptorHost);
            }
            final String parentApplicationName = parentInfo.getParentApplicationName();
            if (StringUtils.hasLength(parentApplicationName)) {
                spanBo.setParentApplicationId(parentApplicationName);
            }
            spanBo.setParentApplicationServiceType((short) parentInfo.getParentApplicationType());
        }
    }
    // because exceptionInfo is the error information of span itself, exceptionInfo can be null even if errCode is not 0
    if (pSpan.hasExceptionInfo()) {
        final PIntStringValue exceptionInfo = pSpan.getExceptionInfo();
        spanBo.setExceptionInfo(exceptionInfo.getIntValue(), getExceptionMessage(exceptionInfo));
    }
    List<AnnotationBo> annotationBoList = buildAnnotationList(pSpan.getAnnotationList());
    spanBo.setAnnotationBoList(annotationBoList);
    return spanBo;
}
Also used : AnnotationBo(com.navercorp.pinpoint.common.server.bo.AnnotationBo) PIntStringValue(com.navercorp.pinpoint.grpc.trace.PIntStringValue) PParentInfo(com.navercorp.pinpoint.grpc.trace.PParentInfo) PAcceptEvent(com.navercorp.pinpoint.grpc.trace.PAcceptEvent) SpanBo(com.navercorp.pinpoint.common.server.bo.SpanBo) PTransactionId(com.navercorp.pinpoint.grpc.trace.PTransactionId) TransactionId(com.navercorp.pinpoint.common.profiler.util.TransactionId)

Aggregations

PAcceptEvent (com.navercorp.pinpoint.grpc.trace.PAcceptEvent)3 PIntStringValue (com.navercorp.pinpoint.grpc.trace.PIntStringValue)2 PParentInfo (com.navercorp.pinpoint.grpc.trace.PParentInfo)2 PTransactionId (com.navercorp.pinpoint.grpc.trace.PTransactionId)2 Shared (com.navercorp.pinpoint.profiler.context.id.Shared)2 TraceId (com.navercorp.pinpoint.bootstrap.context.TraceId)1 VisibleForTesting (com.navercorp.pinpoint.common.annotations.VisibleForTesting)1 TransactionId (com.navercorp.pinpoint.common.profiler.util.TransactionId)1 AnnotationBo (com.navercorp.pinpoint.common.server.bo.AnnotationBo)1 SpanBo (com.navercorp.pinpoint.common.server.bo.SpanBo)1 IntStringValue (com.navercorp.pinpoint.common.util.IntStringValue)1 PAnnotation (com.navercorp.pinpoint.grpc.trace.PAnnotation)1 PSpan (com.navercorp.pinpoint.grpc.trace.PSpan)1 PSpanEvent (com.navercorp.pinpoint.grpc.trace.PSpanEvent)1 Annotation (com.navercorp.pinpoint.profiler.context.Annotation)1 SpanEvent (com.navercorp.pinpoint.profiler.context.SpanEvent)1 TraceRoot (com.navercorp.pinpoint.profiler.context.id.TraceRoot)1