Search in sources :

Example 86 with SpanEventBo

use of com.navercorp.pinpoint.common.server.bo.SpanEventBo in project pinpoint by naver.

the class SpanAsyncEventMap method toAlignList.

private List<Align> toAlignList(SpanBo spanBo, SpanChunkBo spanChunkBo, List<SpanEventBo> spanEventBoList) {
    List<Align> alignList = new ArrayList<>(spanEventBoList.size());
    for (SpanEventBo spanEventBo : spanEventBoList) {
        SpanChunkEventAlign spanChunkEventAlign = new SpanChunkEventAlign(spanBo, spanChunkBo, spanEventBo);
        alignList.add(spanChunkEventAlign);
    }
    return alignList;
}
Also used : ArrayList(java.util.ArrayList) SpanEventBo(com.navercorp.pinpoint.common.server.bo.SpanEventBo)

Example 87 with SpanEventBo

use of com.navercorp.pinpoint.common.server.bo.SpanEventBo in project pinpoint by naver.

the class TraceService method insertSpanEventList.

private void insertSpanEventList(List<SpanEventBo> spanEventList, ServiceType applicationServiceType, String applicationId, String agentId, String endPoint) {
    for (SpanEventBo spanEvent : spanEventList) {
        final ServiceType spanEventType = registry.findServiceType(spanEvent.getServiceType());
        if (isAlias(spanEventType, spanEvent)) {
            insertAcceptorHost(spanEvent, applicationId, applicationServiceType);
            continue;
        }
        if (!spanEventType.isRecordStatistics()) {
            continue;
        }
        final String spanEventApplicationName = normalize(spanEvent.getDestinationId(), spanEventType);
        final String spanEventEndPoint = spanEvent.getEndPoint();
        // if terminal update statistics
        final int elapsed = spanEvent.getEndElapsed();
        final boolean hasException = spanEvent.hasException();
        if (applicationId == null || spanEventApplicationName == null) {
            logger.warn("Failed to insert statistics. Cause:SpanEvent has invalid format.(application:{}/{}[{}], spanEventApplication:{}[{}])", applicationId, agentId, applicationServiceType, spanEventApplicationName, spanEventType);
            continue;
        }
        /*
             * save information to draw a server map based on statistics
             */
        // save the information of caller (the spanevent that called span)
        statisticsService.updateCaller(applicationId, applicationServiceType, agentId, spanEventApplicationName, spanEventType, spanEventEndPoint, elapsed, hasException);
        // save the information of callee (the span that spanevent called)
        statisticsService.updateCallee(spanEventApplicationName, spanEventType, applicationId, applicationServiceType, endPoint, elapsed, hasException);
    }
}
Also used : ServiceType(com.navercorp.pinpoint.common.trace.ServiceType) SpanEventBo(com.navercorp.pinpoint.common.server.bo.SpanEventBo)

Example 88 with SpanEventBo

use of com.navercorp.pinpoint.common.server.bo.SpanEventBo in project pinpoint by naver.

the class TraceService method insertSpanEventStat.

private void insertSpanEventStat(SpanBo span) {
    final List<SpanEventBo> spanEventList = span.getSpanEventBoList();
    if (CollectionUtils.isEmpty(spanEventList)) {
        return;
    }
    if (logger.isDebugEnabled()) {
        logger.debug("handle spanEvent size:{}", spanEventList.size());
    }
    final ServiceType applicationServiceType = getApplicationServiceType(span);
    // TODO need to batch update later.
    insertSpanEventList(spanEventList, applicationServiceType, span.getApplicationId(), span.getAgentId(), span.getEndPoint());
}
Also used : ServiceType(com.navercorp.pinpoint.common.trace.ServiceType) SpanEventBo(com.navercorp.pinpoint.common.server.bo.SpanEventBo)

Example 89 with SpanEventBo

use of com.navercorp.pinpoint.common.server.bo.SpanEventBo in project pinpoint by naver.

the class AlignComparator method compare.

@Override
public int compare(Align a1, Align a2) {
    final SpanEventBo event1 = a1.getSpanEventBo();
    final SpanEventBo event2 = a2.getSpanEventBo();
    return SpanEventComparator.INSTANCE.compare(event1, event2);
}
Also used : SpanEventBo(com.navercorp.pinpoint.common.server.bo.SpanEventBo)

Example 90 with SpanEventBo

use of com.navercorp.pinpoint.common.server.bo.SpanEventBo 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)

Aggregations

SpanEventBo (com.navercorp.pinpoint.common.server.bo.SpanEventBo)94 Test (org.junit.Test)39 SpanBo (com.navercorp.pinpoint.common.server.bo.SpanBo)26 AnnotationBo (com.navercorp.pinpoint.common.server.bo.AnnotationBo)14 SpanChunkBo (com.navercorp.pinpoint.common.server.bo.SpanChunkBo)13 ServiceType (com.navercorp.pinpoint.common.trace.ServiceType)11 ArrayList (java.util.ArrayList)11 Buffer (com.navercorp.pinpoint.common.buffer.Buffer)9 ByteBuffer (java.nio.ByteBuffer)8 AutomaticBuffer (com.navercorp.pinpoint.common.buffer.AutomaticBuffer)4 LocalAsyncIdBo (com.navercorp.pinpoint.common.server.bo.LocalAsyncIdBo)4 Header (com.navercorp.pinpoint.grpc.Header)4 PSpanChunk (com.navercorp.pinpoint.grpc.trace.PSpanChunk)4 TSpanEvent (com.navercorp.pinpoint.thrift.dto.TSpanEvent)4 SpanAcceptor (com.navercorp.pinpoint.web.filter.visitor.SpanAcceptor)4 SpanEventVisitor (com.navercorp.pinpoint.web.filter.visitor.SpanEventVisitor)4 SpanReader (com.navercorp.pinpoint.web.filter.visitor.SpanReader)4 OffsetFixedBuffer (com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer)3 SpanBitFiled (com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.bitfield.SpanBitFiled)3 PSpanEvent (com.navercorp.pinpoint.grpc.trace.PSpanEvent)3