Search in sources :

Example 6 with IntStringValue

use of com.navercorp.pinpoint.common.util.IntStringValue in project pinpoint by naver.

the class SpanThriftMessageConverterTest method buildTSpan.

@Test
public void buildTSpan() {
    final Span span = newSpan();
    span.setStartTime(System.currentTimeMillis());
    span.setElapsedTime(RandomExUtils.nextInt(0, 100));
    span.setAcceptorHost("acceptorHost");
    span.setExceptionInfo(new IntStringValue(RandomExUtils.nextInt(0, 100), "error"));
    span.setApiId(RandomExUtils.nextInt(0, 100));
    span.setServiceType((short) RandomExUtils.nextInt(0, 100));
    span.setRemoteAddr("remoteAddr");
    span.setParentApplicationName("pApp");
    span.setParentApplicationType((short) RandomExUtils.nextInt(0, 100));
    final TraceRoot traceRoot = span.getTraceRoot();
    Shared shared = traceRoot.getShared();
    shared.setEndPoint("endPoint");
    shared.setRpcName("rpcName");
    shared.setLoggingInfo((byte) RandomExUtils.nextInt(0, 10));
    shared.maskErrorCode(RandomExUtils.nextInt(0, 100));
    shared.setStatusCode(RandomExUtils.nextInt(0, 100));
    span.addAnnotation(Annotations.of(1));
    span.setSpanEventList(Collections.singletonList(new SpanEvent()));
    final TSpan tSpan = messageConverter.buildTSpan(span);
    Assert.assertEquals(span.getStartTime(), tSpan.getStartTime());
    Assert.assertEquals(span.getElapsedTime(), tSpan.getElapsed());
    Assert.assertEquals(span.getAcceptorHost(), tSpan.getAcceptorHost());
    Assert.assertEquals(span.getExceptionInfo().getIntValue(), tSpan.getExceptionInfo().getIntValue());
    Assert.assertEquals(span.getExceptionInfo().getStringValue(), tSpan.getExceptionInfo().getStringValue());
    Assert.assertEquals(span.getApiId(), tSpan.getApiId());
    Assert.assertEquals(span.getServiceType(), tSpan.getServiceType());
    Assert.assertEquals(span.getRemoteAddr(), tSpan.getRemoteAddr());
    Assert.assertEquals(span.getParentApplicationName(), tSpan.getParentApplicationName());
    Assert.assertEquals(span.getParentApplicationType(), tSpan.getParentApplicationType());
    Assert.assertEquals(traceRoot.getTraceId().getSpanId(), tSpan.getSpanId());
    Assert.assertEquals(traceRoot.getShared().getEndPoint(), tSpan.getEndPoint());
    Assert.assertEquals(traceRoot.getShared().getRpcName(), tSpan.getRpc());
    Assert.assertEquals(traceRoot.getShared().getLoggingInfo(), tSpan.getLoggingTransactionInfo());
    Assert.assertEquals(traceRoot.getShared().getErrorCode(), tSpan.getErr());
    // TODO
    // Assert.assertEquals(traceRoot.getShared().getStatusCode(),  );
    Assert.assertEquals(span.getAnnotations().size(), tSpan.getAnnotations().size());
    Assert.assertEquals(span.getSpanEventList().size(), tSpan.getSpanEventList().size());
}
Also used : IntStringValue(com.navercorp.pinpoint.common.util.IntStringValue) SpanEvent(com.navercorp.pinpoint.profiler.context.SpanEvent) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) TSpan(com.navercorp.pinpoint.thrift.dto.TSpan) DefaultTraceRoot(com.navercorp.pinpoint.profiler.context.id.DefaultTraceRoot) TraceRoot(com.navercorp.pinpoint.profiler.context.id.TraceRoot) Shared(com.navercorp.pinpoint.profiler.context.id.Shared) TSpan(com.navercorp.pinpoint.thrift.dto.TSpan) Span(com.navercorp.pinpoint.profiler.context.Span) Test(org.junit.Test)

Example 7 with IntStringValue

use of com.navercorp.pinpoint.common.util.IntStringValue in project pinpoint by naver.

the class GrpcAnnotationHandler method newIntStringValue.

private IntStringValue newIntStringValue(Object annotationValue) {
    final PIntStringValue pValue = (PIntStringValue) annotationValue;
    String stringValue = null;
    if (pValue.hasStringValue()) {
        stringValue = pValue.getStringValue().getValue();
    }
    return new IntStringValue(pValue.getIntValue(), stringValue);
}
Also used : PIntStringValue(com.navercorp.pinpoint.grpc.trace.PIntStringValue) IntStringValue(com.navercorp.pinpoint.common.util.IntStringValue) PIntStringValue(com.navercorp.pinpoint.grpc.trace.PIntStringValue)

Example 8 with IntStringValue

use of com.navercorp.pinpoint.common.util.IntStringValue 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 9 with IntStringValue

use of com.navercorp.pinpoint.common.util.IntStringValue 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 10 with IntStringValue

use of com.navercorp.pinpoint.common.util.IntStringValue in project pinpoint by naver.

the class GrpcSpanMessageConverter method buildPIntStringValue.

private PIntStringValue buildPIntStringValue(IntStringValue exceptionInfo) {
    PIntStringValue.Builder builder = PIntStringValue.newBuilder();
    builder.setIntValue(exceptionInfo.getIntValue());
    if (exceptionInfo.getStringValue() != null) {
        final StringValue stringValue = StringValue.of(exceptionInfo.getStringValue());
        builder.setStringValue(stringValue);
    }
    return builder.build();
}
Also used : PIntStringValue(com.navercorp.pinpoint.grpc.trace.PIntStringValue) IntStringValue(com.navercorp.pinpoint.common.util.IntStringValue) StringValue(com.google.protobuf.StringValue) PIntStringValue(com.navercorp.pinpoint.grpc.trace.PIntStringValue)

Aggregations

IntStringValue (com.navercorp.pinpoint.common.util.IntStringValue)16 PIntStringValue (com.navercorp.pinpoint.grpc.trace.PIntStringValue)8 Annotation (com.navercorp.pinpoint.profiler.context.Annotation)5 VisibleForTesting (com.navercorp.pinpoint.common.annotations.VisibleForTesting)4 TIntStringValue (com.navercorp.pinpoint.thrift.dto.TIntStringValue)4 IntStringStringValue (com.navercorp.pinpoint.common.util.IntStringStringValue)3 LongIntIntByteByteStringValue (com.navercorp.pinpoint.common.util.LongIntIntByteByteStringValue)3 StringStringValue (com.navercorp.pinpoint.common.util.StringStringValue)3 PIntStringStringValue (com.navercorp.pinpoint.grpc.trace.PIntStringStringValue)3 PLongIntIntByteByteStringValue (com.navercorp.pinpoint.grpc.trace.PLongIntIntByteByteStringValue)3 PStringStringValue (com.navercorp.pinpoint.grpc.trace.PStringStringValue)3 SpanEvent (com.navercorp.pinpoint.profiler.context.SpanEvent)3 Shared (com.navercorp.pinpoint.profiler.context.id.Shared)3 TraceRoot (com.navercorp.pinpoint.profiler.context.id.TraceRoot)3 TSpanEvent (com.navercorp.pinpoint.thrift.dto.TSpanEvent)3 StringValue (com.google.protobuf.StringValue)2 TraceId (com.navercorp.pinpoint.bootstrap.context.TraceId)2 AutomaticBuffer (com.navercorp.pinpoint.common.buffer.AutomaticBuffer)2 Buffer (com.navercorp.pinpoint.common.buffer.Buffer)2 FixedBuffer (com.navercorp.pinpoint.common.buffer.FixedBuffer)2