protected void logSocket(long millis, int bytesDown, int bytesUp) { if (Sniffy.hasSpies() && null != address && (millis > 0 || bytesDown > 0 || bytesUp > 0)) { Sniffy.logSocket(id, address, millis, bytesDown, bytesUp); } }
protected void logSocket(long millis, int bytesDown, int bytesUp) { if (Sniffy.hasSpies() && null != address && (millis > 0 || bytesDown > 0 || bytesUp > 0)) { Sniffy.logSocket(id, address, millis, bytesDown, bytesUp); } }
protected Object invokeTargetAndRecord(Method method, Object[] args) throws Throwable { if (Sniffy.hasSpies()) { long start = System.currentTimeMillis(); try { Sniffy.enterJdbcMethod(); Object result = invokeTargetImpl(method, args); if (Boolean.TRUE.equals(result)) { Sniffy.readDatabaseRow(method, System.currentTimeMillis() - start, statementMetaData); } return result; } finally { Sniffy.exitJdbcMethod(method, System.currentTimeMillis() - start); } } else { return invokeTargetImpl(method, args); } } }
protected Object invokeTargetAndRecord(Method method, Object[] args) throws Throwable { if (Sniffy.hasSpies()) { long start = System.currentTimeMillis(); try { Sniffy.enterJdbcMethod(); Object result = invokeTargetImpl(method, args); if (Boolean.TRUE.equals(result)) { Sniffy.readDatabaseRow(method, System.currentTimeMillis() - start, statementMetaData); } return result; } finally { Sniffy.exitJdbcMethod(method, System.currentTimeMillis() - start); } } else { return invokeTargetImpl(method, args); } } }
public static void exitJdbcMethod(Method method, long elapsedTime, Method implMethod) { if (Sniffy.hasSpies()) {
public static void exitJdbcMethod(Method method, long elapsedTime, Method implMethod) { if (Sniffy.hasSpies()) {
@Test public void hasSpiesFromOtherThreads() throws Exception { try (@SuppressWarnings("unused") Spy spy = Sniffy.spy()) { AtomicBoolean hasSpies = new AtomicBoolean(); Thread thread = new Thread(() -> hasSpies.set(Sniffy.hasSpies())); thread.start(); thread.join(); assertTrue(hasSpies.get()); } }
@Test public void hasNotSpiesFromOtherThreads() throws Exception { try (@SuppressWarnings("unused") CurrentThreadSpy spy = Sniffy.spyCurrentThread()) { AtomicBoolean hasSpies = new AtomicBoolean(); Thread thread = new Thread(() -> hasSpies.set(Sniffy.hasSpies())); thread.start(); thread.join(); assertFalse(hasSpies.get()); } }
long elapsedTime = System.currentTimeMillis() - start; Sniffy.logSqlTime(sql, elapsedTime); if (Sniffy.hasSpies()) { String stackTrace = printStackTrace(getTraceForProxiedMethod(method)); lastStatementMetaData = Sniffy.executeStatement(sql, elapsedTime, stackTrace, rowsUpdated);
long elapsedTime = System.currentTimeMillis() - start; Sniffy.logSqlTime(sql, elapsedTime); if (Sniffy.hasSpies()) { String stackTrace = printStackTrace(getTraceForProxiedMethod(method)); lastStatementMetaData = Sniffy.executeStatement(sql, elapsedTime, stackTrace, rowsUpdated);