Search in sources :

Example 6 with LogDataEntity

use of org.apache.skywalking.apm.agent.core.context.trace.LogDataEntity in project incubator-skywalking by apache.

the class XMemcachedMethodInterceptorTest method assertLogData.

private void assertLogData(List<LogDataEntity> logDataEntities) {
    assertThat(logDataEntities.size(), is(1));
    LogDataEntity logData = logDataEntities.get(0);
    Assert.assertThat(logData.getLogs().size(), is(4));
    Assert.assertThat(logData.getLogs().get(0).getValue(), CoreMatchers.<Object>is("error"));
    Assert.assertThat(logData.getLogs().get(1).getValue(), CoreMatchers.<Object>is(RuntimeException.class.getName()));
    Assert.assertNull(logData.getLogs().get(2).getValue());
    TestCase.assertNotNull(logData.getLogs().get(3).getValue());
}
Also used : LogDataEntity(org.apache.skywalking.apm.agent.core.context.trace.LogDataEntity)

Example 7 with LogDataEntity

use of org.apache.skywalking.apm.agent.core.context.trace.LogDataEntity in project incubator-skywalking by apache.

the class ResinV3InterceptorTest method testWithOccurException.

@Test
public void testWithOccurException() throws Throwable {
    interceptor.beforeMethod(enhancedInstance, null, arguments, argumentType, methodInterceptResult);
    interceptor.handleMethodException(enhancedInstance, null, arguments, argumentType, new RuntimeException());
    interceptor.afterMethod(enhancedInstance, null, arguments, argumentType, null);
    assertThat(segmentStorage.getTraceSegments().size(), is(1));
    TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
    List<AbstractTracingSpan> spans = SegmentHelper.getSpans(traceSegment);
    assertHttpSpan(spans.get(0));
    List<LogDataEntity> logDataEntities = SpanHelper.getLogs(spans.get(0));
    assertThat(logDataEntities.size(), is(1));
    SpanAssert.assertException(logDataEntities.get(0), RuntimeException.class);
}
Also used : AbstractTracingSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan) LogDataEntity(org.apache.skywalking.apm.agent.core.context.trace.LogDataEntity) TraceSegment(org.apache.skywalking.apm.agent.core.context.trace.TraceSegment) Test(org.junit.Test)

Example 8 with LogDataEntity

use of org.apache.skywalking.apm.agent.core.context.trace.LogDataEntity in project incubator-skywalking by apache.

the class ResinV4InterceptorTest method testWithOccurException.

@Test
public void testWithOccurException() throws Throwable {
    interceptor.beforeMethod(enhancedInstance, null, arguments, argumentType, methodInterceptResult);
    interceptor.handleMethodException(enhancedInstance, null, arguments, argumentType, new RuntimeException());
    interceptor.afterMethod(enhancedInstance, null, arguments, argumentType, null);
    assertThat(segmentStorage.getTraceSegments().size(), is(1));
    TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
    List<AbstractTracingSpan> spans = SegmentHelper.getSpans(traceSegment);
    assertHttpSpan(spans.get(0));
    List<LogDataEntity> logDataEntities = SpanHelper.getLogs(spans.get(0));
    assertThat(logDataEntities.size(), is(1));
    SpanAssert.assertException(logDataEntities.get(0), RuntimeException.class);
}
Also used : AbstractTracingSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan) LogDataEntity(org.apache.skywalking.apm.agent.core.context.trace.LogDataEntity) TraceSegment(org.apache.skywalking.apm.agent.core.context.trace.TraceSegment) Test(org.junit.Test)

Example 9 with LogDataEntity

use of org.apache.skywalking.apm.agent.core.context.trace.LogDataEntity in project incubator-skywalking by apache.

the class Struts2InterceptorTest method testWithOccurException.

@Test
public void testWithOccurException() throws Throwable {
    struts2Interceptor.beforeMethod(enhancedInstance, null, arguments, argumentType, methodInterceptResult);
    struts2Interceptor.handleMethodException(enhancedInstance, null, arguments, argumentType, new RuntimeException());
    struts2Interceptor.afterMethod(enhancedInstance, null, arguments, argumentType, null);
    assertThat(segmentStorage.getTraceSegments().size(), is(1));
    TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
    List<AbstractTracingSpan> spans = SegmentHelper.getSpans(traceSegment);
    assertHttpSpan(spans.get(0));
    List<LogDataEntity> logDataEntities = SpanHelper.getLogs(spans.get(0));
    assertThat(logDataEntities.size(), is(1));
    assertException(logDataEntities.get(0), RuntimeException.class);
}
Also used : AbstractTracingSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan) LogDataEntity(org.apache.skywalking.apm.agent.core.context.trace.LogDataEntity) TraceSegment(org.apache.skywalking.apm.agent.core.context.trace.TraceSegment) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 10 with LogDataEntity

use of org.apache.skywalking.apm.agent.core.context.trace.LogDataEntity in project incubator-skywalking by apache.

the class TomcatInvokeInterceptorTest method testWithTomcatException.

@Test
public void testWithTomcatException() throws Throwable {
    tomcatInvokeInterceptor.beforeMethod(enhancedInstance, null, arguments, argumentType, methodInterceptResult);
    tomcatExceptionInterceptor.beforeMethod(enhancedInstance, null, exceptionArguments, exceptionArgumentType, null);
    tomcatInvokeInterceptor.afterMethod(enhancedInstance, null, arguments, argumentType, null);
    assertThat(segmentStorage.getTraceSegments().size(), is(1));
    TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
    List<AbstractTracingSpan> spans = SegmentHelper.getSpans(traceSegment);
    assertHttpSpan(spans.get(0));
    List<LogDataEntity> logDataEntities = SpanHelper.getLogs(spans.get(0));
    assertThat(logDataEntities.size(), is(1));
    SpanAssert.assertException(logDataEntities.get(0), RuntimeException.class);
}
Also used : AbstractTracingSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan) LogDataEntity(org.apache.skywalking.apm.agent.core.context.trace.LogDataEntity) TraceSegment(org.apache.skywalking.apm.agent.core.context.trace.TraceSegment) Test(org.junit.Test)

Aggregations

LogDataEntity (org.apache.skywalking.apm.agent.core.context.trace.LogDataEntity)20 AbstractTracingSpan (org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan)15 TraceSegment (org.apache.skywalking.apm.agent.core.context.trace.TraceSegment)15 Test (org.junit.Test)13 InputStream (java.io.InputStream)2 Method (java.lang.reflect.Method)2 BigDecimal (java.math.BigDecimal)2 ResultSet (java.sql.ResultSet)2 SQLException (java.sql.SQLException)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 Response (feign.Response)1 CallableStatement (java.sql.CallableStatement)1 PreparedStatement (java.sql.PreparedStatement)1 AbstractSpan (org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan)1 TraceSegmentRef (org.apache.skywalking.apm.agent.core.context.trace.TraceSegmentRef)1 KeyValuePair (org.apache.skywalking.apm.agent.core.context.util.KeyValuePair)1 ServletRequestAttributes (org.springframework.web.context.request.ServletRequestAttributes)1