Search in sources :

Example 1 with RecordSql

use of com.newrelic.agent.bridge.datastore.RecordSql in project newrelic-java-agent by newrelic.

the class SlowQueryInfo method getQuery.

public String getQuery() {
    String query = obfuscatedQuery;
    // TransactionData can be null but by the time we get here it will already be checked for null and excluded
    TransactionTracerConfig ttConfig = getTransactionData().getTransactionTracerConfig();
    RecordSql recordSql = RecordSql.get(ttConfig.getRecordSql());
    if (recordSql == RecordSql.raw) {
        query = rawQuery;
    }
    return TransactionSegment.truncateSql(query, ttConfig.getInsertSqlMaxLength());
}
Also used : RecordSql(com.newrelic.agent.bridge.datastore.RecordSql) TransactionTracerConfig(com.newrelic.agent.config.TransactionTracerConfig)

Example 2 with RecordSql

use of com.newrelic.agent.bridge.datastore.RecordSql in project newrelic-java-agent by newrelic.

the class DefaultExplainPlanExecutorTest method testMultipleStatementNoExplainPlan.

@Test
public void testMultipleStatementNoExplainPlan() throws SQLException {
    SqlTracerExplainInfo tracer = createSqlTracerInfo("SELECT * FROM users; SELECT * FROM users");
    DefaultExplainPlanExecutor explainPlanExecutor = new DefaultExplainPlanExecutor(tracer, (String) tracer.getSql(), RecordSql.raw);
    explainPlanExecutor.runExplainPlan(null, null, new DatabaseVendor() {

        @Override
        public String getName() {
            return "MyDBVendor";
        }

        @Override
        public String getType() {
            return "MyDB";
        }

        @Override
        public boolean isExplainPlanSupported() {
            return true;
        }

        @Override
        public String getExplainPlanSql(String sql) throws SQLException {
            return sql;
        }

        @Override
        public Collection<Collection<Object>> parseExplainPlanResultSet(int columnCount, ResultSet rs, RecordSql recordSql) throws SQLException {
            return null;
        }

        @Override
        public String getExplainPlanFormat() {
            return null;
        }

        @Override
        public DatastoreVendor getDatastoreVendor() {
            return DatastoreVendor.JDBC;
        }
    });
    assertFalse(tracer.hasExplainPlan());
}
Also used : SqlTracerExplainInfo(com.newrelic.agent.tracers.SqlTracerExplainInfo) DatastoreVendor(com.newrelic.agent.bridge.datastore.DatastoreVendor) DatabaseVendor(com.newrelic.agent.bridge.datastore.DatabaseVendor) SQLException(java.sql.SQLException) RecordSql(com.newrelic.agent.bridge.datastore.RecordSql) ResultSet(java.sql.ResultSet) Collection(java.util.Collection) Test(org.junit.Test)

Aggregations

RecordSql (com.newrelic.agent.bridge.datastore.RecordSql)2 DatabaseVendor (com.newrelic.agent.bridge.datastore.DatabaseVendor)1 DatastoreVendor (com.newrelic.agent.bridge.datastore.DatastoreVendor)1 TransactionTracerConfig (com.newrelic.agent.config.TransactionTracerConfig)1 SqlTracerExplainInfo (com.newrelic.agent.tracers.SqlTracerExplainInfo)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 Collection (java.util.Collection)1 Test (org.junit.Test)1