use of org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan in project incubator-skywalking by apache.
the class DefaultHttpClientInterceptorTest method testMethodsAroundError.
@Test
public void testMethodsAroundError() throws Throwable {
defaultHttpClientInterceptor.beforeMethod(enhancedInstance, null, allArguments, argumentTypes, result);
Response response = mock(Response.class);
when(response.status()).thenReturn(404);
defaultHttpClientInterceptor.afterMethod(enhancedInstance, null, allArguments, argumentTypes, response);
assertThat(segmentStorage.getTraceSegments().size(), is(1));
TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
Assert.assertEquals(1, SegmentHelper.getSpans(traceSegment).size());
AbstractTracingSpan finishedSpan = SegmentHelper.getSpans(traceSegment).get(0);
assertSpan(finishedSpan);
List<KeyValuePair> tags = SpanHelper.getTags(finishedSpan);
assertThat(tags.size(), is(3));
assertThat(tags.get(0).getValue(), is("GET"));
assertThat(tags.get(1).getValue(), is("http://skywalking.org/"));
assertThat(tags.get(2).getValue(), is("404"));
Assert.assertEquals(true, SpanHelper.getErrorOccurred(finishedSpan));
}
use of org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan in project incubator-skywalking by apache.
the class StateInterceptorTest method testHttpClient.
@Test
public void testHttpClient() throws Throwable {
AbstractSpan span = ContextManager.createLocalSpan("httpasyncclient/HttpAsyncRequestExecutor:");
stateInterceptor.beforeMethod(enhancedInstance, null, allArguments, argumentsType, null);
stateInterceptor.afterMethod(enhancedInstance, null, allArguments, argumentsType, httpResponse);
processResponseInterceptor.beforeMethod(enhancedInstance, null, allArguments, argumentsType, null);
processResponseInterceptor.afterMethod(enhancedInstance, null, allArguments, argumentsType, httpResponse);
Assert.assertThat(segmentStorage.getTraceSegments().size(), is(1));
TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
List<AbstractTracingSpan> spans = SegmentHelper.getSpans(traceSegment);
assertHttpSpan(spans.get(0));
verify(request, times(1)).setHeader(anyString(), anyString());
}
use of org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan in project incubator-skywalking by apache.
the class SWCallableStatementTest method testQuerySqlWithSql.
@Test
public void testQuerySqlWithSql() throws SQLException {
CallableStatement preparedStatement = swConnection.prepareCall("SELECT * FROM test", 1, 1);
ResultSet resultSet = preparedStatement.executeQuery("SELECT * FROM test");
preparedStatement.getGeneratedKeys();
preparedStatement.close();
verify(mysqlCallableStatement, times(1)).executeQuery(anyString());
verify(mysqlCallableStatement, times(1)).close();
assertThat(segmentStorage.getTraceSegments().size(), is(1));
TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
List<AbstractTracingSpan> spans = SegmentHelper.getSpans(traceSegment);
assertThat(spans.size(), is(1));
assertDBSpan(spans.get(0), "Mysql/JDBI/CallableStatement/executeQuery", "SELECT * FROM test");
}
use of org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan in project incubator-skywalking by apache.
the class SWCallableStatementTest method testInsertWithIntColumnIndexes.
@Test
public void testInsertWithIntColumnIndexes() throws SQLException {
CallableStatement preparedStatement = swConnection.prepareCall("INSERT INTO test VALUES(?)");
boolean insertCount = preparedStatement.execute("INSERT INTO test VALUES(1)", new int[] { 1, 2 });
preparedStatement.close();
verify(mysqlCallableStatement, times(1)).close();
assertThat(segmentStorage.getTraceSegments().size(), is(1));
TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
List<AbstractTracingSpan> spans = SegmentHelper.getSpans(traceSegment);
assertThat(spans.size(), is(1));
assertDBSpan(spans.get(0), "Mysql/JDBI/CallableStatement/execute", "INSERT INTO test VALUES(1)");
}
use of org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan in project incubator-skywalking by apache.
the class SWCallableStatementTest method testInsertWithStringColumnIndexes.
@Test
public void testInsertWithStringColumnIndexes() throws SQLException {
CallableStatement preparedStatement = swConnection.prepareCall("INSERT INTO test VALUES(?)");
boolean insertCount = preparedStatement.execute("INSERT INTO test VALUES(1)", new String[] { "1", "2" });
preparedStatement.close();
verify(mysqlCallableStatement, times(1)).close();
assertThat(segmentStorage.getTraceSegments().size(), is(1));
TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
List<AbstractTracingSpan> spans = SegmentHelper.getSpans(traceSegment);
assertThat(spans.size(), is(1));
assertDBSpan(spans.get(0), "Mysql/JDBI/CallableStatement/execute", "INSERT INTO test VALUES(1)");
}
Aggregations