-
Notifications
You must be signed in to change notification settings - Fork 154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
User Pluggable Connection Time Trace Logger #1077
Conversation
// if the dev provided an impl, we assume they meant to time trace the connection | ||
traceConnection = true; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the old impl just had the traceConnection
flag. Since we are switching to an interface/impl, this checks the flag and makes the appropriate impl. If the flag is false, the impl is a no-op, which is actually less operations than the old implementation that would call a method, pass a the traceConnection flag and check the flag even when trace connection is off. The no-op is just a method call as a comparison.
@@ -1774,6 +1811,7 @@ private Options(Builder b) { | |||
this.reconnectDelayHandler = b.reconnectDelayHandler; | |||
|
|||
this.errorListener = b.errorListener == null ? new ErrorListenerLoggerImpl() : b.errorListener; | |||
this.timeTraceLogger = b.timeTraceLogger; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the builder prepares it and now also prepares the error listener for consistency
} | ||
this.unprocessedServers = b.unprocessedServers; // exactly how the user gave them | ||
this.natsServerUris = Collections.unmodifiableList(b.natsServerUris); | ||
this.unprocessedServers = Collections.unmodifiableList(b.unprocessedServers); // exactly how the user gave them |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1.After reviewing the builder, I noticed that natsServerUris
was already never empty so that was unnecessary.
2. All lists, since they can be viewed from public api needs to be unmodifiable.
Yes. Fully understood. So the use cases are from my PoV:
|
Ok let's think about places where we can safely add logging into. Anything around Connection/Reconnects. Anything around JetStreamManagement, but that's high level, so not sure how that is useful. I know sometimes the errors are IOException and it's kinda useless. Where else? |
Examples from my Pov:
|
} | ||
else { | ||
double seconds = ((double) remaining) / 1_000_000_000.0; | ||
timeTraceLogger.trace(message + String.format(", %.3f (s) remaining", seconds)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block is the change to reporting the time check
assertTrue(traces.get(i++).startsWith("starting ping and cleanup timers")); | ||
assertTrue(traces.get(i++).startsWith("updating status to connected")); | ||
assertTrue(traces.get(i++).startsWith("status updated")); | ||
assertTrue(traces.get(i).startsWith("connect complete")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is assuring backward compatibility on messages in case someone was relying on them in logs.
nc.traceTimeCheck("lt 0, lt -1_000_000_000", -1_100_000_000); | ||
assertEquals("lt 0, lt -1_000_000_000, 1.100 (s) beyond timeout", l.lastTrace); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tests the new implementation of time check reporting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Allow users to provide a replacement for the trace logging feature. Currently it's just simple check a flag / write to the console.
This change provides a fully backward compatible implementation that can be overridden per connection.
Also Fixed
Also fixed timeCheck reporting