use of com.navercorp.pinpoint.common.trace.AnnotationKey in project pinpoint by naver.
the class DefaultAnnotationKeyRegistryService method buildAnnotationKeyRegistry.
private AnnotationKeyRegistry buildAnnotationKeyRegistry() {
AnnotationKeyRegistry.Builder builder = new AnnotationKeyRegistry.Builder();
StaticFieldLookUp<AnnotationKey> staticFieldLookUp = new StaticFieldLookUp<AnnotationKey>(AnnotationKey.class, AnnotationKey.class);
List<AnnotationKey> lookup = staticFieldLookUp.lookup();
for (AnnotationKey serviceType : lookup) {
if (logger.isInfoEnabled()) {
logger.info("add Default AnnotationKey:" + serviceType);
}
builder.addAnnotationKey(serviceType);
}
final List<AnnotationKey> types = typeLoaderService.getAnnotationKeys();
for (AnnotationKey type : types) {
if (logger.isInfoEnabled()) {
logger.info("add Plugin AnnotationKey:" + type);
}
builder.addAnnotationKey(type);
}
return builder.build();
}
use of com.navercorp.pinpoint.common.trace.AnnotationKey in project pinpoint by naver.
the class AnnotationKeyTest method getCode.
@Test
public void getCode() {
TraceMetadataLoaderService typeLoaderService = new DefaultTraceMetadataLoaderService();
AnnotationKeyRegistryService annotationKeyRegistryService = new DefaultAnnotationKeyRegistryService(typeLoaderService, StdoutCommonLoggerFactory.INSTANCE);
AnnotationKey annotationKey = annotationKeyRegistryService.findAnnotationKey(AnnotationKey.API.getCode());
Assert.assertEquals(annotationKey, AnnotationKey.API);
}
use of com.navercorp.pinpoint.common.trace.AnnotationKey in project pinpoint by naver.
the class PluginTestAgent method verifySpan.
private void verifySpan(ResolvedExpectedTrace expected, ActualTrace actual) {
if (!expected.type.equals(actual.getType())) {
throw new AssertionError("Expected an instance of " + expected.type.getSimpleName() + " but was " + actual.getType().getName() + ". expected: " + expected + ", was: " + actual);
}
if (!equals(expected.serviceType.getCode(), actual.getServiceType())) {
throw new AssertionError("Expected a " + expected.type.getSimpleName() + " with serviceType[" + expected.serviceType.getCode() + "] but was [" + actual.getServiceType() + "]. expected: " + expected + ", was: " + actual);
}
if (!equals(expected.apiId, actual.getApiId())) {
throw new AssertionError("Expected a " + expected.type.getSimpleName() + " with apiId[" + expected.apiId + "] but was [" + actual.getApiId() + "]. expected: " + expected + ", was: " + actual);
}
if (!equals(expected.rpc, actual.getRpc())) {
throw new AssertionError("Expected a " + expected.type.getSimpleName() + " with rpc[" + expected.rpc + "] but was [" + actual.getRpc() + "]. expected: " + expected + ", was: " + actual);
}
if (!equals(expected.endPoint, actual.getEndPoint())) {
throw new AssertionError("Expected a " + expected.type.getSimpleName() + " with endPoint[" + expected.endPoint + "] but was [" + actual.getEndPoint() + "]. expected: " + expected + ", was: " + actual);
}
if (!equals(expected.remoteAddr, actual.getRemoteAddr())) {
throw new AssertionError("Expected a " + expected.type.getSimpleName() + " with remoteAddr[" + expected.remoteAddr + "] but was [" + actual.getRemoteAddr() + "]. expected: " + expected + ", was: " + actual);
}
if (!equals(expected.destinationId, actual.getDestinationId())) {
throw new AssertionError("Expected a " + expected.type.getSimpleName() + " with destinationId[" + expected.destinationId + "] but was [" + actual.getDestinationId() + "]. expected: " + expected + ", was: " + actual);
}
if (!equals(expected.asyncId, actual.getAsyncId())) {
throw new AssertionError("Expected a " + expected.type.getSimpleName() + " with asyncId[" + expected.asyncId + "] but was [" + actual.getAsyncId() + "]. expected: " + expected + ", was: " + actual);
}
List<TAnnotation> actualAnnotations = actual.getAnnotations();
int len = expected.annotations == null ? 0 : expected.annotations.length;
int actualLen = actualAnnotations == null ? 0 : actualAnnotations.size();
if (actualLen != len) {
throw new AssertionError("Expected [" + len + "] annotations but was [" + actualLen + "], expected: " + expected + ", was: " + actual);
}
for (int i = 0; i < len; i++) {
ExpectedAnnotation expect = expected.annotations[i];
AnnotationKey expectedAnnotationKey = annotationKeyRegistryService.findAnnotationKeyByName(expect.getKeyName());
TAnnotation actualAnnotation = actualAnnotations.get(i);
if (expectedAnnotationKey.getCode() != actualAnnotation.getKey()) {
throw new AssertionError("Expected " + i + "th annotation [" + expectedAnnotationKey.getCode() + "=" + expect.getValue() + "] but was [" + toString(actualAnnotation) + "], expected: " + expected + ", was: " + actual);
}
if (expectedAnnotationKey == AnnotationKey.SQL_ID && expect instanceof ExpectedSql) {
verifySql((ExpectedSql) expect, actualAnnotation);
} else {
Object expectedValue = expect.getValue();
if (expectedValue == Expectations.anyAnnotationValue()) {
continue;
}
if (AnnotationKeyUtils.isCachedArgsKey(expectedAnnotationKey.getCode())) {
expectedValue = getTestTcpDataSender().getStringId(expectedValue.toString());
}
if (!Objects.equal(expectedValue, actualAnnotation.getValue().getFieldValue())) {
throw new AssertionError("Expected " + i + "th annotation [" + expectedAnnotationKey.getCode() + "=" + expect.getValue() + "] but was [" + toString(actualAnnotation) + "], expected: " + expected + ", was: " + actual);
}
}
}
}
Aggregations