Search in sources :

Example 1 with Annotation

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

the class GrpcSpanMessageConverter method buildPSpanEvent.

@VisibleForTesting
public PSpanEvent.Builder buildPSpanEvent(SpanEvent spanEvent) {
    final PSpanEvent.Builder pSpanEvent = getSpanEventBuilder();
    // tSpanEvent.setStartElapsed(spanEvent.getStartElapsed());
    if (spanEvent.getElapsedTime() != 0) {
        pSpanEvent.setEndElapsed(spanEvent.getElapsedTime());
    }
    pSpanEvent.setSequence(spanEvent.getSequence());
    // tSpanEvent.setRpc(spanEvent.getRpc());
    pSpanEvent.setServiceType(spanEvent.getServiceType());
    // tSpanEvent.setAnnotations();
    if (spanEvent.getDepth() != -1) {
        pSpanEvent.setDepth(spanEvent.getDepth());
    }
    pSpanEvent.setApiId(spanEvent.getApiId());
    final IntStringValue exceptionInfo = spanEvent.getExceptionInfo();
    if (exceptionInfo != null) {
        PIntStringValue pIntStringValue = buildPIntStringValue(exceptionInfo);
        pSpanEvent.setExceptionInfo(pIntStringValue);
    }
    final PNextEvent nextEvent = buildNextEvent(spanEvent);
    if (nextEvent != null) {
        pSpanEvent.setNextEvent(nextEvent);
    }
    final AsyncId asyncIdObject = spanEvent.getAsyncIdObject();
    if (asyncIdObject != null) {
        pSpanEvent.setAsyncEvent(asyncIdObject.getAsyncId());
    }
    final List<Annotation<?>> annotations = spanEvent.getAnnotations();
    if (CollectionUtils.hasLength(annotations)) {
        final List<PAnnotation> pAnnotations = buildPAnnotation(annotations);
        pSpanEvent.addAllAnnotation(pAnnotations);
    }
    return pSpanEvent;
}
Also used : PNextEvent(com.navercorp.pinpoint.grpc.trace.PNextEvent) PIntStringValue(com.navercorp.pinpoint.grpc.trace.PIntStringValue) PAnnotation(com.navercorp.pinpoint.grpc.trace.PAnnotation) IntStringValue(com.navercorp.pinpoint.common.util.IntStringValue) PIntStringValue(com.navercorp.pinpoint.grpc.trace.PIntStringValue) PLocalAsyncId(com.navercorp.pinpoint.grpc.trace.PLocalAsyncId) AsyncId(com.navercorp.pinpoint.profiler.context.AsyncId) LocalAsyncId(com.navercorp.pinpoint.profiler.context.LocalAsyncId) PSpanEvent(com.navercorp.pinpoint.grpc.trace.PSpanEvent) Annotation(com.navercorp.pinpoint.profiler.context.Annotation) PAnnotation(com.navercorp.pinpoint.grpc.trace.PAnnotation) VisibleForTesting(com.navercorp.pinpoint.common.annotations.VisibleForTesting)

Example 2 with Annotation

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

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

the class PluginVerifierExternalAdaptor method verifySpan.

private void verifySpan(final ResolvedExpectedTrace expected, ActualTrace actual) {
    if (!expected.type.equals(actual.getType())) {
        AssertionErrorBuilder builder = new AssertionErrorBuilder(expected.type.getSimpleName() + " InstanceType", expected.type.getSimpleName(), actual.getType().getName());
        builder.setComparison(expected, actual);
        builder.throwAssertionError();
    }
    if (!equals(expected.serviceType.getCode(), actual.getServiceType())) {
        AssertionErrorBuilder builder = new AssertionErrorBuilder(expected.type.getSimpleName() + ".serviceType", expected.serviceType.getCode(), actual.getServiceType());
        builder.setComparison(expected, actual);
        builder.throwAssertionError();
    }
    if (!equals(expected.apiId, actual.getApiId())) {
        AssertionErrorBuilder builder = new AssertionErrorBuilder(expected.type.getSimpleName() + ".apiId", expected.apiId, actual.getApiId());
        builder.setComparison(expected, actual);
        builder.throwAssertionError();
    }
    if (!equals(expected.rpc, actual.getRpc())) {
        AssertionErrorBuilder builder = new AssertionErrorBuilder(expected.type.getSimpleName() + ".rpc", expected.rpc, actual.getRpc());
        builder.setComparison(expected, actual);
        builder.throwAssertionError();
    }
    if (!equals(expected.endPoint, actual.getEndPoint())) {
        AssertionErrorBuilder builder = new AssertionErrorBuilder(expected.type.getSimpleName() + ".endPoint", expected.endPoint, actual.getEndPoint());
        builder.setComparison(expected, actual);
        builder.throwAssertionError();
    }
    if (!equals(expected.remoteAddr, actual.getRemoteAddr())) {
        AssertionErrorBuilder builder = new AssertionErrorBuilder(expected.type.getSimpleName() + ".remoteAddr", expected.remoteAddr, actual.getRemoteAddr());
        builder.setComparison(expected, actual);
        builder.throwAssertionError();
    }
    if (!equals(expected.destinationId, actual.getDestinationId())) {
        AssertionErrorBuilder builder = new AssertionErrorBuilder(expected.type.getSimpleName() + ".destinationId", expected.destinationId, actual.getDestinationId());
        builder.setComparison(expected, actual);
        builder.throwAssertionError();
    }
    if (!equals(getAsyncId(expected), actual.getAsyncId())) {
        AssertionErrorBuilder builder = new AssertionErrorBuilder(expected.type.getSimpleName() + ".asyncId", expected.localAsyncId, actual.getAsyncId());
        builder.setComparison(expected, actual);
        builder.throwAssertionError();
    }
    if (expected.exception != null) {
        final IntStringValue actualExceptionInfo = actual.getExceptionInfo();
        if (actualExceptionInfo != null) {
            String actualExceptionClassName = this.handler.getTcpDataSender().getString(actualExceptionInfo.getIntValue());
            String actualExceptionMessage = actualExceptionInfo.getStringValue();
            verifyException(expected.exception, actualExceptionClassName, actualExceptionMessage);
        } else {
            AssertionErrorBuilder builder = new AssertionErrorBuilder(expected.type.getSimpleName() + ".exception", expected.exception.getClass().getName(), null);
            builder.throwAssertionError();
        }
    }
    List<Annotation<?>> actualAnnotations = actual.getAnnotations();
    final int expectedLen = ArrayUtils.getLength(expected.annotations);
    final int actualLen = CollectionUtils.nullSafeSize(actualAnnotations);
    if (actualLen != expectedLen) {
        AssertionErrorBuilder builder = new AssertionErrorBuilder("Annotation.length", expectedLen, actualLen);
        builder.setComparison(expected, actual);
        builder.throwAssertionError();
    }
    for (int i = 0; i < expectedLen; i++) {
        annotationCompare(i, expected, actual, actualAnnotations.get(i));
    }
}
Also used : AssertionErrorBuilder(com.navercorp.pinpoint.test.util.AssertionErrorBuilder) IntStringValue(com.navercorp.pinpoint.common.util.IntStringValue) ExpectedAnnotation(com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedAnnotation) Annotation(com.navercorp.pinpoint.profiler.context.Annotation)

Example 4 with Annotation

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

the class SpanThriftMessageConverter method buildTSpanEvent.

@VisibleForTesting
TSpanEvent buildTSpanEvent(SpanEvent spanEvent) {
    final TSpanEvent tSpanEvent = new TSpanEvent();
    // tSpanEvent.setStartElapsed(spanEvent.getStartElapsed());
    if (spanEvent.getElapsedTime() != 0) {
        tSpanEvent.setEndElapsed(spanEvent.getElapsedTime());
    }
    tSpanEvent.setSequence((short) spanEvent.getSequence());
    // tSpanEvent.setRpc(spanEvent.getRpc());
    tSpanEvent.setServiceType(spanEvent.getServiceType());
    tSpanEvent.setEndPoint(spanEvent.getEndPoint());
    // tSpanEvent.setAnnotations();
    if (spanEvent.getDepth() != -1) {
        tSpanEvent.setDepth(spanEvent.getDepth());
    }
    if (spanEvent.getNextSpanId() != -1) {
        tSpanEvent.setNextSpanId(spanEvent.getNextSpanId());
    }
    tSpanEvent.setDestinationId(spanEvent.getDestinationId());
    tSpanEvent.setApiId(spanEvent.getApiId());
    final IntStringValue exceptionInfo = spanEvent.getExceptionInfo();
    if (exceptionInfo != null) {
        TIntStringValue tIntStringValue = buildTIntStringValue(exceptionInfo);
        tSpanEvent.setExceptionInfo(tIntStringValue);
    }
    final AsyncId asyncIdObject = spanEvent.getAsyncIdObject();
    if (asyncIdObject != null) {
        tSpanEvent.setNextAsyncId(asyncIdObject.getAsyncId());
    }
    final List<Annotation<?>> annotations = spanEvent.getAnnotations();
    if (CollectionUtils.hasLength(annotations)) {
        final List<TAnnotation> tAnnotations = buildTAnnotation(annotations);
        tSpanEvent.setAnnotations(tAnnotations);
    }
    return tSpanEvent;
}
Also used : TIntStringValue(com.navercorp.pinpoint.thrift.dto.TIntStringValue) IntStringValue(com.navercorp.pinpoint.common.util.IntStringValue) TIntStringValue(com.navercorp.pinpoint.thrift.dto.TIntStringValue) TLocalAsyncId(com.navercorp.pinpoint.thrift.dto.TLocalAsyncId) AsyncId(com.navercorp.pinpoint.profiler.context.AsyncId) LocalAsyncId(com.navercorp.pinpoint.profiler.context.LocalAsyncId) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) TAnnotation(com.navercorp.pinpoint.thrift.dto.TAnnotation) Annotation(com.navercorp.pinpoint.profiler.context.Annotation) TAnnotation(com.navercorp.pinpoint.thrift.dto.TAnnotation) VisibleForTesting(com.navercorp.pinpoint.common.annotations.VisibleForTesting)

Example 5 with Annotation

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

the class SpanThriftMessageConverter method buildTSpan.

@VisibleForTesting
TSpan buildTSpan(Span span) {
    final TSpan tSpan = new TSpan();
    // tSpan.setVersion(span.getVersion());
    tSpan.setApplicationName(applicationName);
    tSpan.setAgentId(agentId);
    tSpan.setAgentStartTime(agentStartTime);
    tSpan.setApplicationServiceType(applicationServiceType);
    final TraceRoot traceRoot = span.getTraceRoot();
    final TraceId traceId = traceRoot.getTraceId();
    final ByteBuffer transactionId = transactionIdEncoder.encodeTransactionId(traceId);
    tSpan.setTransactionId(transactionId);
    tSpan.setSpanId(traceId.getSpanId());
    tSpan.setParentSpanId(traceId.getParentSpanId());
    tSpan.setStartTime(span.getStartTime());
    tSpan.setElapsed(span.getElapsedTime());
    tSpan.setServiceType(span.getServiceType());
    tSpan.setRemoteAddr(span.getRemoteAddr());
    final Shared shared = traceRoot.getShared();
    tSpan.setRpc(shared.getRpcName());
    tSpan.setEndPoint(shared.getEndPoint());
    tSpan.setFlag(traceId.getFlags());
    tSpan.setErr(shared.getErrorCode());
    tSpan.setParentApplicationName(span.getParentApplicationName());
    tSpan.setParentApplicationType(span.getParentApplicationType());
    tSpan.setAcceptorHost(span.getAcceptorHost());
    tSpan.setApiId(span.getApiId());
    final IntStringValue exceptionInfo = span.getExceptionInfo();
    if (exceptionInfo != null) {
        TIntStringValue tIntStringValue = buildTIntStringValue(exceptionInfo);
        tSpan.setExceptionInfo(tIntStringValue);
    }
    tSpan.setLoggingTransactionInfo(shared.getLoggingInfo());
    final List<Annotation<?>> annotations = span.getAnnotations();
    if (CollectionUtils.hasLength(annotations)) {
        final List<TAnnotation> tAnnotations = buildTAnnotation(annotations);
        tSpan.setAnnotations(tAnnotations);
    }
    spanPostProcessor.preProcess(span, tSpan);
    final List<SpanEvent> spanEventList = span.getSpanEventList();
    if (CollectionUtils.hasLength(spanEventList)) {
        final List<TSpanEvent> tSpanEvents = buildTSpanEventList(spanEventList);
        tSpan.setSpanEventList(tSpanEvents);
    }
    spanPostProcessor.postProcess(span, tSpan);
    return tSpan;
}
Also used : TIntStringValue(com.navercorp.pinpoint.thrift.dto.TIntStringValue) Shared(com.navercorp.pinpoint.profiler.context.id.Shared) ByteBuffer(java.nio.ByteBuffer) TAnnotation(com.navercorp.pinpoint.thrift.dto.TAnnotation) Annotation(com.navercorp.pinpoint.profiler.context.Annotation) TAnnotation(com.navercorp.pinpoint.thrift.dto.TAnnotation) IntStringValue(com.navercorp.pinpoint.common.util.IntStringValue) TIntStringValue(com.navercorp.pinpoint.thrift.dto.TIntStringValue) SpanEvent(com.navercorp.pinpoint.profiler.context.SpanEvent) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) TSpan(com.navercorp.pinpoint.thrift.dto.TSpan) TraceId(com.navercorp.pinpoint.bootstrap.context.TraceId) TraceRoot(com.navercorp.pinpoint.profiler.context.id.TraceRoot) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) VisibleForTesting(com.navercorp.pinpoint.common.annotations.VisibleForTesting)

Aggregations

IntStringValue (com.navercorp.pinpoint.common.util.IntStringValue)5 Annotation (com.navercorp.pinpoint.profiler.context.Annotation)5 VisibleForTesting (com.navercorp.pinpoint.common.annotations.VisibleForTesting)4 TraceId (com.navercorp.pinpoint.bootstrap.context.TraceId)2 PAnnotation (com.navercorp.pinpoint.grpc.trace.PAnnotation)2 PIntStringValue (com.navercorp.pinpoint.grpc.trace.PIntStringValue)2 PSpanEvent (com.navercorp.pinpoint.grpc.trace.PSpanEvent)2 AsyncId (com.navercorp.pinpoint.profiler.context.AsyncId)2 LocalAsyncId (com.navercorp.pinpoint.profiler.context.LocalAsyncId)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 TAnnotation (com.navercorp.pinpoint.thrift.dto.TAnnotation)2 TIntStringValue (com.navercorp.pinpoint.thrift.dto.TIntStringValue)2 TSpanEvent (com.navercorp.pinpoint.thrift.dto.TSpanEvent)2 ExpectedAnnotation (com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedAnnotation)1 PAcceptEvent (com.navercorp.pinpoint.grpc.trace.PAcceptEvent)1 PLocalAsyncId (com.navercorp.pinpoint.grpc.trace.PLocalAsyncId)1 PNextEvent (com.navercorp.pinpoint.grpc.trace.PNextEvent)1 PSpan (com.navercorp.pinpoint.grpc.trace.PSpan)1