Search in sources :

Example 6 with StatementEnhanceInfos

use of org.apache.skywalking.apm.plugin.jdbc.define.StatementEnhanceInfos 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);
}
Also used : ConnectionInfo(org.apache.skywalking.apm.plugin.jdbc.trace.ConnectionInfo) StatementEnhanceInfos(org.apache.skywalking.apm.plugin.jdbc.define.StatementEnhanceInfos) AbstractSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan)

Example 7 with StatementEnhanceInfos

use of org.apache.skywalking.apm.plugin.jdbc.define.StatementEnhanceInfos 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);
}
Also used : ConnectionInfo(org.apache.skywalking.apm.plugin.jdbc.trace.ConnectionInfo) StatementEnhanceInfos(org.apache.skywalking.apm.plugin.jdbc.define.StatementEnhanceInfos) AbstractSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan)

Aggregations

StatementEnhanceInfos (org.apache.skywalking.apm.plugin.jdbc.define.StatementEnhanceInfos)7 AbstractSpan (org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan)6 ConnectionInfo (org.apache.skywalking.apm.plugin.jdbc.trace.ConnectionInfo)6 Before (org.junit.Before)1