use of org.apache.skywalking.apm.plugin.jdbc.trace.ConnectionInfo in project incubator-skywalking by apache.
the class PreparedStatementExecuteMethodsInterceptor method beforeMethod.
@Override
public final void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
StatementEnhanceInfos cacheObject = (StatementEnhanceInfos) objInst.getSkyWalkingDynamicField();
ConnectionInfo connectInfo = cacheObject.getConnectionInfo();
AbstractSpan span = ContextManager.createExitSpan(buildOperationName(connectInfo, method.getName(), cacheObject.getStatementName()), connectInfo.getDatabasePeer());
Tags.DB_TYPE.set(span, "sql");
Tags.DB_INSTANCE.set(span, connectInfo.getDatabaseName());
Tags.DB_STATEMENT.set(span, cacheObject.getSql());
span.setComponent(connectInfo.getComponent());
SpanLayer.asDB(span);
}
use of org.apache.skywalking.apm.plugin.jdbc.trace.ConnectionInfo in project incubator-skywalking by apache.
the class StatementExecuteMethodsInterceptor method beforeMethod.
@Override
public final void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
StatementEnhanceInfos cacheObject = (StatementEnhanceInfos) objInst.getSkyWalkingDynamicField();
ConnectionInfo connectInfo = cacheObject.getConnectionInfo();
/**
* To protected the code occur NullPointException. because mysql execute system sql when constructor method in
* {@link com.mysql.jdbc.ConnectionImpl} class executed. but the interceptor set the connection Info after
* the constructor method executed.
*
* @see JDBCDriverInterceptor#afterMethod(EnhancedInstance, Method, Object[], Class[], Object)
*/
if (connectInfo != null) {
AbstractSpan span = ContextManager.createExitSpan(buildOperationName(connectInfo, method.getName(), cacheObject.getStatementName()), connectInfo.getDatabasePeer());
Tags.DB_TYPE.set(span, "sql");
Tags.DB_INSTANCE.set(span, connectInfo.getDatabaseName());
/**
* The first argument of all intercept method in `com.mysql.jdbc.StatementImpl` class is SQL, except the
* `executeBatch` method that the jdbc plugin need to trace, because of this method argument size is zero.
*/
String sql = "";
if (allArguments.length > 0) {
sql = (String) allArguments[0];
}
Tags.DB_STATEMENT.set(span, sql);
span.setComponent(connectInfo.getComponent());
SpanLayer.asDB(span);
}
}
use of org.apache.skywalking.apm.plugin.jdbc.trace.ConnectionInfo in project incubator-skywalking by apache.
the class PreparedStatementExecuteMethodsInterceptor method beforeMethod.
@Override
public final void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
StatementEnhanceInfos cacheObject = (StatementEnhanceInfos) objInst.getSkyWalkingDynamicField();
ConnectionInfo connectInfo = cacheObject.getConnectionInfo();
AbstractSpan span = ContextManager.createExitSpan(buildOperationName(connectInfo, method.getName(), cacheObject.getStatementName()), connectInfo.getDatabasePeer());
Tags.DB_TYPE.set(span, "sql");
Tags.DB_INSTANCE.set(span, connectInfo.getDatabaseName());
Tags.DB_STATEMENT.set(span, cacheObject.getSql());
span.setComponent(connectInfo.getComponent());
SpanLayer.asDB(span);
}
use of org.apache.skywalking.apm.plugin.jdbc.trace.ConnectionInfo in project incubator-skywalking by apache.
the class StatementExecuteMethodsInterceptor method beforeMethod.
@Override
public final void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
StatementEnhanceInfos cacheObject = (StatementEnhanceInfos) objInst.getSkyWalkingDynamicField();
ConnectionInfo connectInfo = cacheObject.getConnectionInfo();
AbstractSpan span = ContextManager.createExitSpan(buildOperationName(connectInfo, method.getName(), cacheObject.getStatementName()), connectInfo.getDatabasePeer());
Tags.DB_TYPE.set(span, "sql");
Tags.DB_INSTANCE.set(span, connectInfo.getDatabaseName());
Tags.DB_STATEMENT.set(span, (String) allArguments[0]);
span.setComponent(connectInfo.getComponent());
SpanLayer.asDB(span);
}
use of org.apache.skywalking.apm.plugin.jdbc.trace.ConnectionInfo in project incubator-skywalking by apache.
the class StatementExecuteMethodsInterceptor method beforeMethod.
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
StatementEnhanceInfos cacheObject = (StatementEnhanceInfos) objInst.getSkyWalkingDynamicField();
ConnectionInfo connectInfo = cacheObject.getConnectionInfo();
AbstractSpan span = ContextManager.createExitSpan(buildOperationName(connectInfo, method.getName(), cacheObject.getStatementName()), connectInfo.getDatabasePeer());
Tags.DB_TYPE.set(span, "sql");
Tags.DB_INSTANCE.set(span, connectInfo.getDatabaseName());
String sql = "";
if (allArguments.length > 0) {
sql = (String) allArguments[0];
}
Tags.DB_STATEMENT.set(span, sql);
span.setComponent(connectInfo.getComponent());
SpanLayer.asDB(span);
}
Aggregations