Skip to content

Conversation

@jrhee17
Copy link
Contributor

@jrhee17 jrhee17 commented Nov 11, 2025

Motivation:

When using xDS based clients, users will often want to know how the xDS resources translate to the load balancer which routes requests upstream.
This changeset attempts introduce a DefaultXdsLoadBalancerLifecycleObserver which collects metrics of each load balancer for each cluster.
This observer has the same lifecycle as a ClusterResourceNode, and will deregister each metric upon close.

Note that thanks to XdsClusterManager, each cluster has a unique name.

Modifications:

  • A DefaultXdsLoadBalancerLifecycleObserver is introduced which records metrics for a XdsLoadBalancer
  • MeterRegistry, MeterIdPrefix can now be specified in XdsBootstrapBuilder
    • MeterRegistry, MeterIdPrefix is also added to SubscriptionContext so that they can be accessed when dynamically querying xDS resources
    • An xDS-dedicated EventExecutor is used for the default event loop.

Result:

  • DefaultXdsLoadBalancerLifecycleObserver now records metrics for XdsLoadBalancers by default

@jrhee17 jrhee17 added this to the 1.34.0 milestone Nov 11, 2025
@jrhee17 jrhee17 marked this pull request as ready for review November 12, 2025 00:33
Copy link
Contributor

@ikhoon ikhoon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍👍

Comment on lines +106 to +107
final ImmutableList.Builder<Meter> metersBuilder = ImmutableList.builder();
metersBuilder.add(Gauge.builder(prefix.name("lb.state.subsets"), () -> numSubsets)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Collection seems unnecessary.

localClusterName = bootstrap.getClusterManager().getLocalClusterName();
if (!Strings.isNullOrEmpty(localClusterName) && bootstrap.getNode().hasLocality()) {
final DefaultXdsLoadBalancerLifecycleObserver observer =
new DefaultXdsLoadBalancerLifecycleObserver(meterIdPrefix, meterRegistry, localClusterName);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that there’s still no extension point for users to configure a custom XdsLoadBalancerLifecycleObserver.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants