use of com.palantir.util.jmx.OperationTimer.TimingState in project atlasdb by palantir.
the class DbKvsGetRanges method getFirstPages.
private Map<RangeRequest, TokenBackedBasicResultsPage<RowResult<Value>, byte[]>> getFirstPages(TableReference tableRef, List<RangeRequest> requests, long timestamp) {
List<String> subQueries = Lists.newArrayList();
List<Object> argsList = Lists.newArrayList();
for (int i = 0; i < requests.size(); i++) {
RangeRequest request = requests.get(i);
Pair<String, List<Object>> queryAndArgs = getRangeQueryAndArgs(tableRef, request.getStartInclusive(), request.getEndExclusive(), request.isReverse(), request.getBatchHint() == null ? 1 : request.getBatchHint(), i);
subQueries.add(queryAndArgs.lhSide);
argsList.addAll(queryAndArgs.rhSide);
}
String query = Joiner.on(") UNION ALL (").appendTo(new StringBuilder("("), subQueries).append(")").toString();
Object[] args = argsList.toArray();
TimingState timer = logTimer.begin("Table: " + tableRef.getQualifiedName() + " get_page");
try {
return getFirstPagesFromDb(tableRef, requests, timestamp, query, args);
} finally {
timer.end();
}
}
use of com.palantir.util.jmx.OperationTimer.TimingState in project atlasdb by palantir.
the class SqlStatsSqlTimer method start.
@Override
public Handle start(String module, final String sqlKey, final String rawSql) {
final TimingState timingState;
if (LoggerFactory.getLogger("com.palantir.nexus.db.SQL").isTraceEnabled()) {
String sql = rawSql.replaceAll("[\n]+", "");
String msg = System.currentTimeMillis() + "\tSQL\t" + module + "\t" + sql;
timingState = timer.begin(msg);
} else {
timingState = null;
}
return () -> {
if (timingState != null && logger.isTraceEnabled()) {
timingState.end();
}
};
}
Aggregations