Skip to content

Commit

Permalink
Merge pull request #5139 from MeroRai/FISH-1084-community
Browse files Browse the repository at this point in the history
FISH-1084 NullPointerException when getting monitoring data for JDBC
  • Loading branch information
MeroRai authored Feb 26, 2021
2 parents 0e01683 + 9d84f7b commit 9d22e9c
Showing 1 changed file with 19 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,15 +209,17 @@ public CountStatistic getNumStatementCacheMiss() {

@ManagedAttribute(id="frequsedsqlqueries")
public ListStatistic getfreqUsedSqlQueries() {
List<SQLTrace> sqlTraces = freqSqlTraceCache.getTopQueries();
freqUsedSqlQueries = new ListStatisticImpl("frequsedsqlqueries", "List", "Most frequently used sql queries");

for (SQLTrace trace : sqlTraces){
CountStatisticImpl stat = new CountStatisticImpl(trace.getQueryName(), "Count", "");
stat.setCount(trace.getNumExecutions());
freqUsedSqlQueries.add(stat);
if (freqSqlTraceCache != null) {
List<SQLTrace> sqlTraces = freqSqlTraceCache.getTopQueries();
freqUsedSqlQueries = new ListStatisticImpl("frequsedsqlqueries", "List", "Most frequently used sql queries");

for (SQLTrace trace : sqlTraces) {
CountStatisticImpl stat = new CountStatisticImpl(trace.getQueryName(), "Count", "");
stat.setCount(trace.getNumExecutions());
freqUsedSqlQueries.add(stat);
}
}

return freqUsedSqlQueries;
}

Expand All @@ -226,12 +228,15 @@ public ListStatistic getSlowSqlQueries() {
//Make sure no data from previous execution is kept
slowSqlQueries.reset();
slowSqlQueries.clear();
//Get slow queries and process them
List<SlowSqlTrace> slowTraces = slowSqlTraceCache.getSlowestSqlQueries();
for (SlowSqlTrace trace: slowTraces){
CountStatisticImpl stat = new CountStatisticImpl(trace.getQueryName(), StatisticImpl.UNIT_MILLISECOND, "Longest execution time");
stat.setCount(trace.getSlowestExecutionTime());
slowSqlQueries.add(stat);

if (slowSqlTraceCache != null) {
//Get slow queries and process them
List<SlowSqlTrace> slowTraces = slowSqlTraceCache.getSlowestSqlQueries();
for (SlowSqlTrace trace : slowTraces) {
CountStatisticImpl stat = new CountStatisticImpl(trace.getQueryName(), StatisticImpl.UNIT_MILLISECOND, "Longest execution time");
stat.setCount(trace.getSlowestExecutionTime());
slowSqlQueries.add(stat);
}
}

return slowSqlQueries;
Expand Down

0 comments on commit 9d22e9c

Please sign in to comment.