Hi Julian,

On Fri, Apr 1, 2016 at 5:19 PM,  <[email protected]> wrote:
> +    @Nonnull
> +    private Connection getConnection() throws IllegalStateException, 
> SQLException {
> +        long ts = System.currentTimeMillis();
> +        Connection c = getDataSource().getConnection();
> +        if (LOG.isDebugEnabled()) {
> +            long elapsed = System.currentTimeMillis() - ts;
> +            if (elapsed >= 100) {
> +                LOG.debug("Obtaining a new connection from " + this.ds + " 
> took " + elapsed + "ms");
> +            }
> +        }
> +        return c;
> +    }

You can also use PerfLogger here which is also used in other places in
DocumentNodeStore

---
final PerfLogger PERFLOG = new PerfLogger(
            LoggerFactory.getLogger(DocumentNodeStore.class.getName()
+ ".perf"));

final long start = PERFLOG.start();
Connection c = getDataSource().getConnection();
PERFLOG.end(start, 100, "Obtaining a new connection from {} ", ds);
---

This would also avoid the call to System.currentTimeMillis() if debug
log is not enabled

Chetan Mehrotra

Reply via email to