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());
}
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);
}
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));
}
}
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;
}
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();
}
Aggregations