use of com.navercorp.pinpoint.common.server.bo.AnnotationBo in project pinpoint by naver.
the class RpcURLPatternFilter method accept.
@Override
public boolean accept(List<SpanBo> fromSpanList) {
for (SpanBo spanBo : fromSpanList) {
final List<SpanEventBo> spanEventBoList = spanBo.getSpanEventBoList();
if (CollectionUtils.isEmpty(spanEventBoList)) {
return REJECT;
}
for (SpanEventBo event : spanEventBoList) {
final ServiceType eventServiceType = serviceTypeRegistryService.findServiceType(event.getServiceType());
if (!eventServiceType.isRpcClient()) {
continue;
}
if (!eventServiceType.isRecordStatistics()) {
continue;
}
// http://api.domain.com/test/ArticleList.do
// slice url ->/test/ArticleList.do
final List<AnnotationBo> annotationBoList = event.getAnnotationBoList();
if (annotationBoList == null) {
continue;
}
for (AnnotationBo annotationBo : annotationBoList) {
// TODO ?? url format & annotation type detect
int key = annotationBo.getKey();
if (isURL(key)) {
String url = (String) annotationBo.getValue();
String path = getPath(url);
final boolean match = matcher.match(urlPattern, path);
if (match) {
return ACCEPT;
}
}
}
}
}
return REJECT;
}
use of com.navercorp.pinpoint.common.server.bo.AnnotationBo in project pinpoint by naver.
the class RecordFactory method getAnnotations.
public List<Record> getAnnotations(final int depth, final int parentId, Align align) {
List<Record> list = new ArrayList<>();
for (AnnotationBo annotation : align.getAnnotationBoList()) {
final AnnotationKey key = findAnnotationKey(annotation.getKey());
if (key.isViewInRecordSet()) {
final String title = this.annotationRecordFormatter.formatTitle(key, annotation, align);
final String arguments = this.annotationRecordFormatter.formatArguments(key, annotation, align);
final Record record = new AnnotationRecord(depth, getNextId(), parentId, title, arguments, annotation.isAuthorized());
list.add(record);
}
}
return list;
}
use of com.navercorp.pinpoint.common.server.bo.AnnotationBo in project pinpoint by naver.
the class LinkFilterTest method wasToWasFilter_noMatch_missingReceivingSpan.
@Test
public void wasToWasFilter_noMatch_missingReceivingSpan() {
final ServiceType tomcat = serviceTypeRegistryService.findServiceTypeByName(TOMCAT_TYPE_NAME);
final String rpcHost = "some.domain.name";
final String rpcUrl = "http://" + rpcHost + "/some/test/path";
FilterDescriptor.FromNode fromNode = new FilterDescriptor.FromNode("APP_A", tomcat.getName(), null);
FilterDescriptor.ToNode toNode = new FilterDescriptor.ToNode("APP_B", tomcat.getName(), null);
FilterDescriptor.SelfNode selfNode = new FilterDescriptor.SelfNode(null, null, null);
FilterDescriptor.ResponseTime responseTime = new FilterDescriptor.ResponseTime(null, null);
FilterDescriptor.Option option = mock(FilterDescriptor.Option.class);
FilterDescriptor descriptor = new FilterDescriptor(fromNode, toNode, selfNode, responseTime, option);
FilterHint emptyHint = new FilterHint(Collections.emptyList());
FilterHint unmatchingHint = new FilterHint(Collections.singletonList(new RpcHint("APP_B", Collections.singletonList(new RpcType("different.domain.name", RPC_TYPE_CODE)))));
FilterHint matchingHint = new FilterHint(Collections.singletonList(new RpcHint("APP_B", Collections.singletonList(new RpcType(rpcHost, RPC_TYPE_CODE)))));
LinkFilter emptyHintLinkFilter = newLinkFilter(descriptor, emptyHint);
LinkFilter unmatchingHintLinkFilter = newLinkFilter(descriptor, unmatchingHint);
LinkFilter matchingHintLinkFilter = newLinkFilter(descriptor, matchingHint);
logger.debug("emptyHintLinkFilter : {}", emptyHintLinkFilter.toString());
logger.debug("unmatchingHintLinkFilter : {}", unmatchingHintLinkFilter.toString());
logger.debug("matchingHintLinkFilter : {}", matchingHintLinkFilter.toString());
SpanBo fromSpan = new SpanBo();
fromSpan.setSpanId(1);
fromSpan.setParentSpanId(-1);
fromSpan.setApplicationId("APP_A");
fromSpan.setApplicationServiceType(tomcat.getCode());
AnnotationBo rpcAnnotation = new AnnotationBo(RPC_ANNOTATION_CODE, rpcUrl);
SpanEventBo rpcSpanEvent = new SpanEventBo();
rpcSpanEvent.setServiceType(RPC_TYPE_CODE);
rpcSpanEvent.setDestinationId(rpcHost);
rpcSpanEvent.setAnnotationBoList(Collections.singletonList(rpcAnnotation));
fromSpan.addSpanEvent(rpcSpanEvent);
// Reject - filter hint empty
Assert.assertFalse(emptyHintLinkFilter.include(Collections.singletonList(fromSpan)));
// Reject - filter hint does not match
Assert.assertFalse(unmatchingHintLinkFilter.include(Collections.singletonList(fromSpan)));
// Accept - filter hint matches
Assert.assertTrue(matchingHintLinkFilter.include(Collections.singletonList(fromSpan)));
// Check rpc url as well
final String unmatchingUrlPattern = "/other/test/**";
final String matchingUrlPattern = "/some/test/**";
// Reject - url pattern does not match
when(option.getUrlPattern()).thenReturn(unmatchingUrlPattern);
LinkFilter matchingHintLinkFilterWithUnmatchingUrlPattern = newLinkFilter(descriptor, matchingHint);
Assert.assertFalse(matchingHintLinkFilterWithUnmatchingUrlPattern.include(Collections.singletonList(fromSpan)));
// Accept - url pattern matches
when(option.getUrlPattern()).thenReturn(matchingUrlPattern);
LinkFilter matchingHintLinkFilterWithMatchingUrlPattern = newLinkFilter(descriptor, matchingHint);
Assert.assertTrue(matchingHintLinkFilterWithMatchingUrlPattern.include(Collections.singletonList(fromSpan)));
}
use of com.navercorp.pinpoint.common.server.bo.AnnotationBo in project pinpoint by naver.
the class LinkFilterTest method wasToUnknownFilter.
@Test
public void wasToUnknownFilter() {
final ServiceType tomcat = serviceTypeRegistryService.findServiceTypeByName(TOMCAT_TYPE_NAME);
final ServiceType unknown = serviceTypeRegistryService.findServiceTypeByName(UNKNOWN_TYPE_NAME);
final String rpcHost = "some.domain.name";
final String rpcUrl = "http://" + rpcHost + "/some/test/path";
final String urlPattern = "/some/test/**";
FilterDescriptor.FromNode fromNode = new FilterDescriptor.FromNode("APP_A", tomcat.getName(), null);
FilterDescriptor.ToNode toNode = new FilterDescriptor.ToNode(rpcHost, unknown.getName(), null);
FilterDescriptor.SelfNode selfNode = new FilterDescriptor.SelfNode(null, null, null);
FilterDescriptor.Option option = new FilterDescriptor.Option(encodeUrl(urlPattern), null);
FilterDescriptor.ResponseTime responseTime = new FilterDescriptor.ResponseTime(null, null);
FilterDescriptor descriptor = new FilterDescriptor(fromNode, toNode, selfNode, responseTime, option);
FilterHint hint = new FilterHint(Collections.emptyList());
LinkFilter linkFilter = newLinkFilter(descriptor, hint);
logger.debug(linkFilter.toString());
// Reject - no rpc span event
SpanBo spanBo = new SpanBo();
spanBo.setSpanId(1);
spanBo.setParentSpanId(-1);
spanBo.setApplicationId("APP_A");
spanBo.setApplicationServiceType(tomcat.getCode());
Assert.assertFalse(linkFilter.include(Collections.singletonList(spanBo)));
// Accept - has matching rpc span event
AnnotationBo rpcAnnotation = new AnnotationBo(RPC_ANNOTATION_CODE, rpcUrl);
SpanEventBo rpcSpanEvent = new SpanEventBo();
rpcSpanEvent.setServiceType(RPC_TYPE_CODE);
rpcSpanEvent.setDestinationId(rpcHost);
rpcSpanEvent.setAnnotationBoList(Collections.singletonList(rpcAnnotation));
spanBo.addSpanEvent(rpcSpanEvent);
Assert.assertTrue(linkFilter.include(Collections.singletonList(spanBo)));
}
use of com.navercorp.pinpoint.common.server.bo.AnnotationBo in project pinpoint by naver.
the class RpcURLPatternFilterTest method createTestRpcSpans.
private List<SpanBo> createTestRpcSpans(String... rpcUrls) {
List<SpanBo> spanBos = new ArrayList<>();
for (String rpcUrl : rpcUrls) {
SpanEventBo testRpcSpanEvent = new SpanEventBo();
testRpcSpanEvent.setServiceType(TEST_RPC_SERVICE_TYPE_CODE);
AnnotationBo testRpcAnnotationBo = new AnnotationBo(TEST_RPC_URL_ANNOTATION_KEY.getCode(), rpcUrl);
testRpcSpanEvent.setAnnotationBoList(Collections.singletonList(testRpcAnnotationBo));
SpanBo spanBo = new SpanBo();
spanBo.addSpanEvent(testRpcSpanEvent);
spanBos.add(spanBo);
}
return spanBos;
}
Aggregations