Skip to content

Commit 73cd03e

Browse files
daschlMichael Nitschinger
authored andcommitted
SPY-157: Fix auth logging times.
Motivation ---------- In the previous commit which added logging, it measured nanoseconds and printed milliseconds. This also screwed up the debug/warn metric. Modifications ------------- Correctly convert nanoseconds to milliseconds. Result ------ Timings are now properly warned and formatted. Change-Id: Id174a49e03e052f9e32c98cc32aa7ad0b82bbb4d Reviewed-on: http://review.couchbase.org/34936 Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com> Reviewed-by: Matt Ingenthron <matt@couchbase.com>
1 parent 6ada2e6 commit 73cd03e

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/main/java/net/spy/memcached/auth/AuthThread.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
package net.spy.memcached.auth;
2525

2626
import java.util.concurrent.CountDownLatch;
27+
import java.util.concurrent.TimeUnit;
2728
import java.util.concurrent.atomic.AtomicBoolean;
2829
import java.util.concurrent.atomic.AtomicReference;
2930

@@ -131,7 +132,8 @@ public void run() {
131132
} else {
132133
supportedMechs = authDescriptor.getMechs();
133134
}
134-
long mechsDiff = System.nanoTime() - mechsStart;
135+
long mechsDiff = TimeUnit.NANOSECONDS.toMillis(System.nanoTime()
136+
- mechsStart);
135137
String msg = String.format("SASL List Mechanisms took %dms on %s",
136138
mechsDiff, node.toString());
137139
Level level = mechsDiff
@@ -186,7 +188,8 @@ public void complete() {
186188
}
187189
done.set(true); // If we were interrupted, tear down.
188190
} finally {
189-
long stepDiff = System.nanoTime() - stepStart;
191+
long stepDiff = TimeUnit.NANOSECONDS.toMillis(System.nanoTime()
192+
- stepStart);
190193
msg = String.format("SASL Step took %dms on %s",
191194
stepDiff, node.toString());
192195
level = mechsDiff
@@ -204,7 +207,8 @@ public void complete() {
204207
}
205208
}
206209

207-
long totalDiff = System.nanoTime() - totalStart;
210+
long totalDiff = TimeUnit.NANOSECONDS.toMillis(System.nanoTime()
211+
- totalStart);
208212
msg = String.format("SASL Auth took %dms on %s",
209213
totalDiff, node.toString());
210214
level = mechsDiff >= AUTH_TOTAL_THRESHOLD ? Level.WARN : Level.DEBUG;

0 commit comments

Comments
 (0)