use of com.newrelic.agent.database.ExplainPlanExecutor in project newrelic-java-agent by newrelic.
the class TransactionTrace method runExplainPlans.
private void runExplainPlans() {
if (!sqlTracers.isEmpty()) {
DatabaseService dbService = ServiceFactory.getDatabaseService();
for (Entry<ConnectionFactory, List<ExplainPlanExecutor>> entry : sqlTracers.entrySet()) {
Agent.LOG.finer(MessageFormat.format("Running {0} explain plan(s)", entry.getValue().size()));
Connection connection = null;
try {
connection = entry.getKey().getConnection();
DatabaseVendor vendor = entry.getKey().getDatabaseVendor();
for (ExplainPlanExecutor explainExecutor : entry.getValue()) {
if (explainExecutor != null) {
explainExecutor.runExplainPlan(dbService, connection, vendor);
}
}
} catch (Throwable t) {
String msg = MessageFormat.format("An error occurred executing an explain plan: {0}", t.toString());
if (Agent.LOG.isLoggable(Level.FINER)) {
Agent.LOG.log(Level.FINER, msg, t);
} else {
Agent.LOG.fine(msg);
}
} finally {
if (connection != null) {
try {
connection.close();
} catch (Exception e) {
Agent.LOG.log(Level.FINER, "Unable to close connection", e);
}
}
}
}
sqlTracers.clear();
}
}
use of com.newrelic.agent.database.ExplainPlanExecutor in project newrelic-java-agent by newrelic.
the class TransactionTrace method processSqlTracer.
private void processSqlTracer(Tracer tracer) {
if (tracer instanceof SqlTracer) {
SqlTracer sqlTracer = (SqlTracer) tracer;
ExplainPlanExecutor explainExecutor = sqlTracer.getExplainPlanExecutor();
ConnectionFactory connectionFactory = sqlTracer.getConnectionFactory();
if (!sqlTracer.hasExplainPlan() && explainExecutor != null && connectionFactory != null) {
List<ExplainPlanExecutor> tracers = sqlTracers.get(connectionFactory);
if (tracers == null) {
tracers = new LinkedList<>();
sqlTracers.put(connectionFactory, tracers);
}
tracers.add(explainExecutor);
}
}
}
Aggregations