-
Notifications
You must be signed in to change notification settings - Fork 467
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
Add diagnostic events for logging visibility #559
Conversation
...s-client/src/main/java/software/amazon/kinesis/coordinator/logging/DiagnosticEventInput.java
Outdated
Show resolved
Hide resolved
...inesis-client/src/main/java/software/amazon/kinesis/coordinator/logging/DiagnosticEvent.java
Outdated
Show resolved
Hide resolved
...s-client/src/main/java/software/amazon/kinesis/coordinator/logging/DiagnosticEventInput.java
Outdated
Show resolved
Hide resolved
...sis-client/src/main/java/software/amazon/kinesis/coordinator/logging/ExecutorStateEvent.java
Outdated
Show resolved
Hide resolved
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.
Initial feedback. Yet to review unit test cases.
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.
Added a few comments. One more comment, this could do without a new java package called logging.
...inesis-client/src/main/java/software/amazon/kinesis/coordinator/logging/DiagnosticEvent.java
Outdated
Show resolved
Hide resolved
...sis-client/src/main/java/software/amazon/kinesis/coordinator/logging/ExecutorStateEvent.java
Outdated
Show resolved
Hide resolved
...esis-client/src/main/java/software/amazon/kinesis/coordinator/logging/RejectedTaskEvent.java
Outdated
Show resolved
Hide resolved
...-client/src/main/java/software/amazon/kinesis/coordinator/DefaultDiagnosticEventHandler.java
Outdated
Show resolved
Hide resolved
amazon-kinesis-client/src/main/java/software/amazon/kinesis/coordinator/RejectedTaskEvent.java
Outdated
Show resolved
Hide resolved
@@ -167,6 +170,9 @@ public Scheduler(@NonNull final CheckpointConfig checkpointConfig, | |||
this.shardConsumerDispatchPollIntervalMillis = this.coordinatorConfig.shardConsumerDispatchPollIntervalMillis(); | |||
this.parentShardPollIntervalMillis = this.coordinatorConfig.parentShardPollIntervalMillis(); | |||
this.executorService = this.coordinatorConfig.coordinatorFactory().createExecutorService(); | |||
this.diagnosticEventHandler = new DefaultDiagnosticEventHandler(); |
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 could come from the config.
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.
Given that we don't want the customer to modify this handler, should this still go in the config?
amazon-kinesis-client/src/main/java/software/amazon/kinesis/coordinator/Scheduler.java
Outdated
Show resolved
Hide resolved
...n-kinesis-client/src/test/java/software/amazon/kinesis/coordinator/DiagnosticEventsTest.java
Outdated
Show resolved
Hide resolved
...n-kinesis-client/src/test/java/software/amazon/kinesis/coordinator/DiagnosticEventsTest.java
Outdated
Show resolved
Hide resolved
...n-kinesis-client/src/test/java/software/amazon/kinesis/coordinator/DiagnosticEventsTest.java
Outdated
Show resolved
Hide resolved
amazon-kinesis-client/src/main/java/software/amazon/kinesis/coordinator/DiagnosticEvent.java
Outdated
Show resolved
Hide resolved
amazon-kinesis-client/src/main/java/software/amazon/kinesis/coordinator/CoordinatorConfig.java
Outdated
Show resolved
Hide resolved
amazon-kinesis-client/src/main/java/software/amazon/kinesis/coordinator/ExecutorStateEvent.java
Outdated
Show resolved
Hide resolved
amazon-kinesis-client/src/main/java/software/amazon/kinesis/coordinator/ExecutorStateEvent.java
Show resolved
Hide resolved
amazon-kinesis-client/src/main/java/software/amazon/kinesis/coordinator/RejectedTaskEvent.java
Outdated
Show resolved
Hide resolved
amazon-kinesis-client/src/main/java/software/amazon/kinesis/coordinator/Scheduler.java
Outdated
Show resolved
Hide resolved
* @param handler This method accepts a handler param solely for testing. All non-test calls to this method will | ||
* have a null input. | ||
*/ | ||
@VisibleForTesting |
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.
Can this be tested as part of runProcessLoop() method?
We want to make sure this is invoked from runProcessLoop.
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.
Changed the unit test for this method to call RxJavaPlugins.onError()
in runProcessLoop() on a scheduler spy to verify that the error handler works as expected
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.
If we get the scheduler take an EventFactory, then we can mock the event vended to the scheduler, and assert that .accept is invoked on the event upon failure.
That way, this method can be marked private, and no need to support custom handler as an argument to this method.
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.
To be able to mock the EventFactory for testability, we would need a public interface for setting/modifying the EventFactory (either in configs or a setter). Currently we don't want users to be able to interact with this factory so this would only solve the problem if we introduced a 'backdoor' non-public setter for testing, which still isn't really designing for testability. Unless there's another way to inject a mock that doesn't rely on a public gateway?
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.
Refactored to use a factory by overloading with a protected constructor for testing
amazon-kinesis-client/src/main/java/software/amazon/kinesis/coordinator/Scheduler.java
Outdated
Show resolved
Hide resolved
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.
Thanks Micah. LGTM, mostly code organization related feedback.
...-kinesis-client/src/main/java/software/amazon/kinesis/coordinator/DiagnosticEventLogger.java
Outdated
Show resolved
Hide resolved
amazon-kinesis-client/src/main/java/software/amazon/kinesis/coordinator/ExecutorStateEvent.java
Outdated
Show resolved
Hide resolved
amazon-kinesis-client/src/main/java/software/amazon/kinesis/coordinator/RejectedTaskEvent.java
Outdated
Show resolved
Hide resolved
amazon-kinesis-client/src/test/java/software/amazon/kinesis/coordinator/SchedulerTest.java
Outdated
Show resolved
Hide resolved
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.
followup up on a unittest comment.
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.
Looking good mostly, just a couple of minor comments. Nothing blocking.
@Slf4j | ||
@KinesisClientInternalApi | ||
class ExecutorStateEvent implements DiagnosticEvent { | ||
private final String MESSAGE = "Current thread pool executor state: "; |
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.
Not a blocker: Seems like this is only used in one place, so doesn't need to be a class variable.
public String message() {
return String.format("Current threadpool executor state: %s", toString());
}
amazon-kinesis-client/src/main/java/software/amazon/kinesis/coordinator/RejectedTaskEvent.java
Outdated
Show resolved
Hide resolved
...n-kinesis-client/src/test/java/software/amazon/kinesis/coordinator/DiagnosticEventsTest.java
Outdated
Show resolved
Hide resolved
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.
Thank you!
Added logging into the executor service for visibility and to help debug complex thread-related issues. Also added an error handler for rejected task exceptions in the RxJava layer to propagate those exceptions up to the KCL layer and log them accordingly.
Per discussion with team we are not providing the flexibility to customize logging or add additional handlers as of now. As a result all new classes in this PR are package-private access.
Example of regular executor state diagnostic:
Example of rejected task logging:
Example logs emitted every 30 seconds from running KCL application:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.