Search in sources :

Example 1 with IsRootSpan

use of com.navercorp.pinpoint.test.junit4.IsRootSpan 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 2 with IsRootSpan

use of com.navercorp.pinpoint.test.junit4.IsRootSpan 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 3 with IsRootSpan

use of com.navercorp.pinpoint.test.junit4.IsRootSpan in project pinpoint by naver.

the class StandardHostValveInvokeModifierTest method invokeShouldBeTraced.

@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);
    assertEquals(rootSpan.getRemoteAddr(), REMOTE_ADDRESS);
}
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 4 with IsRootSpan

use of com.navercorp.pinpoint.test.junit4.IsRootSpan in project pinpoint by naver.

the class StandardHostValveInvokeModifierTest method invokeShouldContinueTracingFromRequest.

@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)

Aggregations

SpanBo (com.navercorp.pinpoint.common.server.bo.SpanBo)4 BasePinpointTest (com.navercorp.pinpoint.test.junit4.BasePinpointTest)4 IsRootSpan (com.navercorp.pinpoint.test.junit4.IsRootSpan)4 Test (org.junit.Test)4