grpc-java icon indicating copy to clipboard operation
grpc-java copied to clipboard

grpc.lb.backend_service is always unset in subchannel metrics

Open ejona86 opened this issue 2 months ago • 0 comments

https://github.com/grpc/proposal/blob/master/A94-subchannel-otel-metrics.md :

Since currently, only xDS is using these labels, the attributes will be set for each endpoint or address by cds (post-A74) or xds_cluster_resolver (pre-A74) LB policies.

cds vs cluster_resolver isn't important; cluster_resolver was merged into cds for A74, so all the code is going to the same place in either case.

I see the code setting locality, but nothing for backend_service: https://github.com/grpc/grpc-java/blob/096c4d9f915fcbef342311a794378194f526bd54/xds/src/main/java/io/grpc/xds/ClusterResolverLoadBalancer.java#L194-L201

I see the code trying to get the backend_service, but it is using a ResolutionResultAttr attribute, which should never be set in the EquivalentAddressGroup: https://github.com/grpc/grpc-java/blob/096c4d9f915fcbef342311a794378194f526bd54/core/src/main/java/io/grpc/internal/InternalSubchannel.java#L607

That attribute is being set today, but it is only in the NameResolver attributes, not in the EAG: https://github.com/grpc/grpc-java/blob/096c4d9f915fcbef342311a794378194f526bd54/xds/src/main/java/io/grpc/xds/ClusterImplLoadBalancer.java#L156-L162

(Note that code will be moving to cds/cluster_resolver to complete A75 in #12431. After that issue and this issue are fixed, all setting of backend_service would be within cds/cluster_resolver.)

ejona86 avatar Oct 21 '25 18:10 ejona86