Search in sources :

Example 16 with SpanBo

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

the class LinkFilter method queueToWasFilter.

/**
     * Queue (virtual) -> WAS
     */
private boolean queueToWasFilter(List<SpanBo> transaction) {
    final List<SpanBo> toNode = findToNode(transaction);
    logger.debug("matching toNode spans: {}", toNode);
    for (SpanBo span : toNode) {
        if (fromApplicationName.equals(span.getAcceptorHost())) {
            if (checkResponseCondition(span.getElapsed(), isError(span))) {
                return true;
            }
        }
    }
    return false;
}
Also used : SpanBo(com.navercorp.pinpoint.common.server.bo.SpanBo)

Example 17 with SpanBo

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

the class LinkFilter method wasToWasExactMatch.

private boolean wasToWasExactMatch(List<SpanBo> fromSpanList, List<SpanBo> toSpanList) {
    // from -> to compare SpanId & pSpanId filter
    for (SpanBo fromSpanBo : fromSpanList) {
        for (SpanBo toSpanBo : toSpanList) {
            if (fromSpanBo == toSpanBo) {
                // skip same object;
                continue;
            }
            if (fromSpanBo.getSpanId() == toSpanBo.getParentSpanId()) {
                final int elapsed = toSpanBo.getElapsed();
                final boolean error = isError(toSpanBo);
                if (checkResponseCondition(elapsed, error)) {
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : SpanBo(com.navercorp.pinpoint.common.server.bo.SpanBo)

Example 18 with SpanBo

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

the class StandardHostValveInvokeModifierTest method invokeShouldContinueTracingFromRequest.

/**
     * Invoke should continue tracing from request.
     *
     * @throws Exception the exception
     */
@Test
@IsRootSpan
public void invokeShouldContinueTracingFromRequest() throws Exception {
    // Given
    // Set Transaction ID from remote source.
    final String sourceAgentId = "agentId";
    final long sourceAgentStartTime = 1234567890123L;
    final long sourceTransactionSequence = 12345678L;
    final String sourceTransactionId = TransactionIdUtils.formatString(sourceAgentId, sourceAgentStartTime, sourceTransactionSequence);
    when(mockRequest.getHeader(Header.HTTP_TRACE_ID.toString())).thenReturn(sourceTransactionId);
    // Set parent Span ID from remote source.
    final long sourceParentId = 99999;
    when(mockRequest.getHeader(Header.HTTP_PARENT_SPAN_ID.toString())).thenReturn(String.valueOf(sourceParentId));
    // When
    host.invoke(mockRequest, mockResponse);
    // Then
    final List<SpanBo> rootSpans = getCurrentRootSpans();
    assertEquals(rootSpans.size(), 1);
    final SpanBo rootSpan = rootSpans.get(0);
    // Check Transaction ID from remote source.
    assertEquals(TransactionIdUtils.formatString(rootSpan.getTransactionId()), sourceTransactionId);
    assertEquals(rootSpan.getTransactionId().getAgentId(), sourceAgentId);
    assertEquals(rootSpan.getTransactionId().getAgentStartTime(), sourceAgentStartTime);
    assertEquals(rootSpan.getTransactionId().getTransactionSequence(), sourceTransactionSequence);
    // Check parent Span ID from remote source.
    assertEquals(rootSpan.getParentSpanId(), sourceParentId);
}
Also used : SpanBo(com.navercorp.pinpoint.common.server.bo.SpanBo) IsRootSpan(com.navercorp.pinpoint.test.junit4.IsRootSpan) BasePinpointTest(com.navercorp.pinpoint.test.junit4.BasePinpointTest) Test(org.junit.Test)

Example 19 with SpanBo

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

the class StandardHostValveInvokeModifierTest method invokeShouldBeTraced.

/**
     * Invoke should be traced.
     *
     * @throws Exception the exception
     */
@Test
@IsRootSpan
public void invokeShouldBeTraced() throws Exception {
    // Given
    // When
    host.invoke(mockRequest, mockResponse);
    // Then
    final List<SpanBo> rootSpans = getCurrentRootSpans();
    assertEquals(rootSpans.size(), 1);
    final SpanBo rootSpan = rootSpans.get(0);
    assertEquals(rootSpan.getParentSpanId(), -1);
    assertEquals(rootSpan.getServiceType(), SERVICE_TYPE.getCode());
    assertEquals(rootSpan.getRpc(), REQUEST_URI);
    assertEquals(rootSpan.getEndPoint(), SERVER_NAME + ":" + SERVER_PORT);
    assertTrue(StringUtils.isNotBlank(rootSpan.getRemoteAddr()));
}
Also used : SpanBo(com.navercorp.pinpoint.common.server.bo.SpanBo) IsRootSpan(com.navercorp.pinpoint.test.junit4.IsRootSpan) BasePinpointTest(com.navercorp.pinpoint.test.junit4.BasePinpointTest) Test(org.junit.Test)

Example 20 with SpanBo

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

the class SpanMapperV2Test method test.

@Test
public void test() {
    SpanBo span = new SpanBo();
    span.setServiceType((short) 1000);
    span.setExceptionInfo(1, "spanException");
    SpanEventBo firstSpanEventBo = new SpanEventBo();
    firstSpanEventBo.setExceptionInfo(2, "first");
    firstSpanEventBo.setEndElapsed(100);
    AnnotationBo annotationBo = newAnnotation(200, "annotation");
    firstSpanEventBo.setAnnotationBoList(Lists.<AnnotationBo>newArrayList(annotationBo));
    firstSpanEventBo.setServiceType((short) 1003);
    firstSpanEventBo.setSequence((short) 0);
    span.addSpanEvent(firstSpanEventBo);
    //// next
    SpanEventBo nextSpanEventBo = new SpanEventBo();
    nextSpanEventBo.setEndElapsed(200);
    nextSpanEventBo.setServiceType((short) 2003);
    nextSpanEventBo.setSequence((short) 1);
    span.addSpanEvent(nextSpanEventBo);
    SpanEncodingContext<SpanBo> encodingContext = new SpanEncodingContext<>(span);
    SpanEncoder encoder = new SpanEncoderV0();
    ByteBuffer byteBuffer = encoder.encodeSpanColumnValue(encodingContext);
    Buffer buffer = new OffsetFixedBuffer(byteBuffer.array(), byteBuffer.arrayOffset(), byteBuffer.remaining());
    SpanBo readSpan = new SpanBo();
    SpanDecodingContext decodingContext = new SpanDecodingContext();
    decoder.readSpanValue(buffer, readSpan, new SpanEventBo(), decodingContext);
    Assert.assertEquals(readSpan.getSpanEventBoList().size(), 2);
    // span
    Assert.assertEquals(readSpan.getServiceType(), 1000);
    Assert.assertEquals(readSpan.hasException(), true);
    Assert.assertEquals(readSpan.getExceptionId(), 1);
    Assert.assertEquals(readSpan.getExceptionMessage(), "spanException");
    List<SpanEventBo> spanEventBoList = readSpan.getSpanEventBoList();
    SpanEventBo readFirst = spanEventBoList.get(0);
    SpanEventBo readNext = spanEventBoList.get(1);
    Assert.assertEquals(readFirst.getEndElapsed(), 100);
    Assert.assertEquals(readNext.getEndElapsed(), 200);
    Assert.assertEquals(readFirst.getExceptionId(), 2);
    Assert.assertEquals(readNext.hasException(), false);
    Assert.assertEquals(readFirst.getServiceType(), 1003);
    Assert.assertEquals(readNext.getServiceType(), 2003);
    Assert.assertEquals(readFirst.getSequence(), 0);
    Assert.assertEquals(readNext.getSequence(), 1);
}
Also used : Buffer(com.navercorp.pinpoint.common.buffer.Buffer) OffsetFixedBuffer(com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer) ByteBuffer(java.nio.ByteBuffer) AnnotationBo(com.navercorp.pinpoint.common.server.bo.AnnotationBo) SpanEncodingContext(com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.SpanEncodingContext) SpanDecodingContext(com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.SpanDecodingContext) SpanEncoder(com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.SpanEncoder) OffsetFixedBuffer(com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer) SpanEncoderV0(com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.SpanEncoderV0) SpanBo(com.navercorp.pinpoint.common.server.bo.SpanBo) ByteBuffer(java.nio.ByteBuffer) SpanEventBo(com.navercorp.pinpoint.common.server.bo.SpanEventBo) Test(org.junit.Test)

Aggregations

SpanBo (com.navercorp.pinpoint.common.server.bo.SpanBo)65 Test (org.junit.Test)32 SpanEventBo (com.navercorp.pinpoint.common.server.bo.SpanEventBo)14 ArrayList (java.util.ArrayList)10 Buffer (com.navercorp.pinpoint.common.buffer.Buffer)8 TransactionId (com.navercorp.pinpoint.common.util.TransactionId)8 OffsetFixedBuffer (com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer)7 ByteBuffer (java.nio.ByteBuffer)7 AnnotationBo (com.navercorp.pinpoint.common.server.bo.AnnotationBo)5 ServiceType (com.navercorp.pinpoint.common.trace.ServiceType)4 BasePinpointTest (com.navercorp.pinpoint.test.junit4.BasePinpointTest)4 IsRootSpan (com.navercorp.pinpoint.test.junit4.IsRootSpan)4 List (java.util.List)4 SpanChunkBo (com.navercorp.pinpoint.common.server.bo.SpanChunkBo)2 SpanDecodingContext (com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.SpanDecodingContext)2 Application (com.navercorp.pinpoint.web.vo.Application)2 Dot (com.navercorp.pinpoint.web.vo.scatter.Dot)2 Cell (org.apache.hadoop.hbase.Cell)2 AutomaticBuffer (com.navercorp.pinpoint.common.buffer.AutomaticBuffer)1 SpanDecodingContext (com.navercorp.pinpoint.common.server.bo.serializer.trace.v1.SpanDecodingContext)1