-
Notifications
You must be signed in to change notification settings - Fork 186
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
loadbalancer: add some logging to RandomSubsetter #3207
loadbalancer: add some logging to RandomSubsetter #3207
Conversation
Motivation: It could be helpful for people to know what happened during subsetting. Modifications: Add some logging to RandomSubsetter. This required some extra changes so that we could pass in the load balancer description so it's easier to know which subsetter we're actually talking about. Result: Better observability.
@@ -71,7 +72,7 @@ private static Set<PrioritizedHost> subsetSet(int randomSubsetSize, List<Priorit | |||
} | |||
|
|||
private static List<PrioritizedHost> subset(int randomSubsetSize, List<PrioritizedHost> hosts) { | |||
return new RandomSubsetter(randomSubsetSize).subset(hosts); | |||
return new RandomSubsetter.RandomSubsetterFactory(randomSubsetSize).build("").subset(hosts); |
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.
Is it a factory or a builder? looks a bit confusing to see a build method on a factory.
Consider either renaming to builder or use "create"/"newSubsetter"/etc. 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.
Good point. Let's go with newSubsetter
.
@@ -56,6 +68,10 @@ public <T extends PrioritizedHost> List<T> subset(List<T> nextHosts) { | |||
} | |||
} | |||
} | |||
if (LOGGER.isDebugEnabled()) { | |||
LOGGER.debug("{}: Using {} hosts out of a total {}. ({} considered unhealthy)", lbDescription, | |||
result.size(), allHosts.size(), result.size() - allHosts.size()); |
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.
Should we log what hosts were picked? Might be worth at debug level
public <T extends PrioritizedHost> List<T> subset(List<T> allHosts) { | ||
if (allHosts.size() <= randomSubsetSize) { | ||
if (LOGGER.isDebugEnabled()) { | ||
LOGGER.debug("{}: Host set size of {} is less than designated subset ({})", |
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.
Should we say what action was made based on that criteria? For example:
"{}: Host set size of {} is less than designated subset ({})", returning all hosts as-is
Motivation:
It could be helpful for people to know what happened during subsetting.
Modifications:
Add some logging to RandomSubsetter. This required some extra changes so that we could pass in the load balancer description so it's easier to know which subsetter we're actually talking about.
Result:
Better observability.