use of org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan in project incubator-skywalking by apache.
the class HttpHostInterceptor method beforeMethod.
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
HttpHost producer = (HttpHost) allArguments[0];
String uri = producer.toURI();
AbstractSpan span = ContextManager.createLocalSpan("httpasyncclient/" + method.getName());
span.setComponent(ComponentsDefine.HTTP_ASYNC_CLIENT).setLayer(SpanLayer.HTTP);
Tags.HTTP.METHOD.set(span, ((HttpRequest) allArguments[1]).getRequestLine().getMethod());
Tags.URL.set(span, uri);
}
use of org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan in project incubator-skywalking by apache.
the class ContextManagerTest method createMultipleExitSpan.
@Test
public void createMultipleExitSpan() {
AbstractSpan entrySpan = ContextManager.createEntrySpan("/testEntrySpan", null);
entrySpan.setComponent(ComponentsDefine.TOMCAT);
Tags.HTTP.METHOD.set(entrySpan, "GET");
Tags.URL.set(entrySpan, "127.0.0.1:8080");
SpanLayer.asHttp(entrySpan);
ContextCarrier firstExitSpanContextCarrier = new ContextCarrier();
AbstractSpan firstExitSpan = ContextManager.createExitSpan("/testFirstExit", firstExitSpanContextCarrier, "127.0.0.1:8080");
firstExitSpan.setComponent(ComponentsDefine.DUBBO);
Tags.URL.set(firstExitSpan, "dubbo://127.0.0.1:8080");
SpanLayer.asRPCFramework(firstExitSpan);
ContextCarrier secondExitSpanContextCarrier = new ContextCarrier();
AbstractSpan secondExitSpan = ContextManager.createExitSpan("/testSecondExit", secondExitSpanContextCarrier, "127.0.0.1:9080");
secondExitSpan.setComponent(ComponentsDefine.TOMCAT);
Tags.HTTP.METHOD.set(secondExitSpan, "GET");
Tags.URL.set(secondExitSpan, "127.0.0.1:8080");
SpanLayer.asHttp(secondExitSpan);
secondExitSpan.setOperationName("/testSecondExit-setOperationName");
ContextManager.stopSpan();
ContextManager.stopSpan();
ContextManager.stopSpan();
assertThat(tracingData.getTraceSegments().size(), is(1));
TraceSegment actualSegment = tracingData.getTraceSegments().get(0);
assertNull(actualSegment.getRefs());
List<AbstractTracingSpan> spanList = SegmentHelper.getSpan(actualSegment);
assertThat(spanList.size(), is(2));
AbstractTracingSpan actualFirstExitSpan = spanList.get(0);
assertThat(actualFirstExitSpan.getOperationName(), is("/testFirstExit"));
assertThat(actualFirstExitSpan.getSpanId(), is(1));
assertThat(AbstractTracingSpanHelper.getParentSpanId(actualFirstExitSpan), is(0));
assertThat(SpanHelper.getComponentId(actualFirstExitSpan), is(ComponentsDefine.DUBBO.getId()));
assertThat(SpanHelper.getLayer(actualFirstExitSpan), is(SpanLayer.RPC_FRAMEWORK));
AbstractTracingSpan actualEntrySpan = spanList.get(1);
assertThat(actualEntrySpan.getOperationName(), is("/testEntrySpan"));
assertThat(actualEntrySpan.getSpanId(), is(0));
assertThat(AbstractTracingSpanHelper.getParentSpanId(actualEntrySpan), is(-1));
assertThat(firstExitSpanContextCarrier.getPeerHost(), is("#127.0.0.1:8080"));
assertThat(firstExitSpanContextCarrier.getSpanId(), is(1));
assertThat(firstExitSpanContextCarrier.getEntryOperationName(), is("#/testEntrySpan"));
assertThat(secondExitSpanContextCarrier.getPeerHost(), is("#127.0.0.1:8080"));
assertThat(secondExitSpanContextCarrier.getSpanId(), is(1));
assertThat(secondExitSpanContextCarrier.getEntryOperationName(), is("#/testEntrySpan"));
}
use of org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan in project incubator-skywalking by apache.
the class StatementTracing method execute.
public static <R> R execute(java.sql.Statement realStatement, ConnectionInfo connectInfo, String method, String sql, Executable<R> exec) throws SQLException {
try {
AbstractSpan span = ContextManager.createExitSpan(connectInfo.getDBType() + "/JDBI/Statement/" + method, connectInfo.getDatabasePeer());
Tags.DB_TYPE.set(span, "sql");
Tags.DB_INSTANCE.set(span, connectInfo.getDatabaseName());
Tags.DB_STATEMENT.set(span, sql);
span.setComponent(connectInfo.getComponent());
SpanLayer.asDB(span);
return exec.exe(realStatement, sql);
} catch (SQLException e) {
AbstractSpan span = ContextManager.activeSpan();
span.errorOccurred();
span.log(e);
throw e;
} finally {
ContextManager.stopSpan();
}
}
use of org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan in project incubator-skywalking by apache.
the class JedisMethodInterceptor method handleMethodException.
@Override
public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, Throwable t) {
AbstractSpan span = ContextManager.activeSpan();
span.errorOccurred();
span.log(t);
}
use of org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan in project incubator-skywalking by apache.
the class JedisMethodInterceptor method beforeMethod.
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
String peer = String.valueOf(objInst.getSkyWalkingDynamicField());
AbstractSpan span = ContextManager.createExitSpan("Jedis/" + method.getName(), peer);
span.setComponent(ComponentsDefine.REDIS);
Tags.DB_TYPE.set(span, "Redis");
SpanLayer.asCache(span);
if (allArguments.length > 0 && allArguments[0] instanceof String) {
Tags.DB_STATEMENT.set(span, method.getName() + " " + allArguments[0]);
}
}
Aggregations