Search in sources :

Example 51 with AnnotationBo

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;
}
Also used : AnnotationBo(com.navercorp.pinpoint.common.server.bo.AnnotationBo) ServiceType(com.navercorp.pinpoint.common.trace.ServiceType) SpanBo(com.navercorp.pinpoint.common.server.bo.SpanBo) SpanEventBo(com.navercorp.pinpoint.common.server.bo.SpanEventBo)

Example 52 with AnnotationBo

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;
}
Also used : AnnotationBo(com.navercorp.pinpoint.common.server.bo.AnnotationBo) ArrayList(java.util.ArrayList) AnnotationKey(com.navercorp.pinpoint.common.trace.AnnotationKey)

Example 53 with AnnotationBo

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)));
}
Also used : SpanBo(com.navercorp.pinpoint.common.server.bo.SpanBo) AnnotationBo(com.navercorp.pinpoint.common.server.bo.AnnotationBo) ServiceType(com.navercorp.pinpoint.common.trace.ServiceType) SpanEventBo(com.navercorp.pinpoint.common.server.bo.SpanEventBo) Test(org.junit.Test)

Example 54 with AnnotationBo

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)));
}
Also used : SpanBo(com.navercorp.pinpoint.common.server.bo.SpanBo) AnnotationBo(com.navercorp.pinpoint.common.server.bo.AnnotationBo) ServiceType(com.navercorp.pinpoint.common.trace.ServiceType) SpanEventBo(com.navercorp.pinpoint.common.server.bo.SpanEventBo) Test(org.junit.Test)

Example 55 with AnnotationBo

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;
}
Also used : AnnotationBo(com.navercorp.pinpoint.common.server.bo.AnnotationBo) ArrayList(java.util.ArrayList) SpanBo(com.navercorp.pinpoint.common.server.bo.SpanBo) SpanEventBo(com.navercorp.pinpoint.common.server.bo.SpanEventBo)

Aggregations

AnnotationBo (com.navercorp.pinpoint.common.server.bo.AnnotationBo)55 ArrayList (java.util.ArrayList)17 SpanEventBo (com.navercorp.pinpoint.common.server.bo.SpanEventBo)14 SpanBo (com.navercorp.pinpoint.common.server.bo.SpanBo)13 ApiMetaDataBo (com.navercorp.pinpoint.common.server.bo.ApiMetaDataBo)7 Test (org.junit.Test)7 List (java.util.List)6 Buffer (com.navercorp.pinpoint.common.buffer.Buffer)5 TransactionId (com.navercorp.pinpoint.common.profiler.util.TransactionId)5 SpanEventBitField (com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.bitfield.SpanEventBitField)5 AnnotationKey (com.navercorp.pinpoint.common.trace.AnnotationKey)5 Align (com.navercorp.pinpoint.web.calltree.span.Align)4 SpanAlign (com.navercorp.pinpoint.web.calltree.span.SpanAlign)4 ByteBuffer (java.nio.ByteBuffer)4 AutomaticBuffer (com.navercorp.pinpoint.common.buffer.AutomaticBuffer)3 SpanBitFiled (com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.bitfield.SpanBitFiled)3 ServiceType (com.navercorp.pinpoint.common.trace.ServiceType)3 OffsetFixedBuffer (com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer)2 SqlMetaDataBo (com.navercorp.pinpoint.common.server.bo.SqlMetaDataBo)2 StringMetaDataBo (com.navercorp.pinpoint.common.server.bo.StringMetaDataBo)2