Skip to content
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

Merged

Conversation

bryce-anderson
Copy link
Contributor

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.

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);
Copy link
Member

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

Copy link
Contributor Author

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());
Copy link
Member

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 ({})",
Copy link
Member

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

@bryce-anderson bryce-anderson merged commit 31eec9a into apple:main Mar 20, 2025
11 checks passed
@bryce-anderson bryce-anderson deleted the bl_anderson/AddLoggingToSubsetter branch March 20, 2025 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants