Skip to content

grpc.lb.backend_service is always unset in subchannel metrics #12432

@ejona86

Description

@ejona86

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:

endpoint.eag().getAttributes().toBuilder()
.set(io.grpc.xds.XdsAttributes.ATTR_LOCALITY, locality)
.set(EquivalentAddressGroup.ATTR_LOCALITY_NAME, localityName)
.set(io.grpc.xds.XdsAttributes.ATTR_LOCALITY_WEIGHT,
localityLbInfo.localityWeight())
.set(io.grpc.xds.XdsAttributes.ATTR_SERVER_WEIGHT, weight)
.set(XdsInternalAttributes.ATTR_ADDRESS_NAME, endpoint.hostname())
.build();

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:

addressIndex.getCurrentEagAttributes(), NameResolver.ATTR_BACKEND_SERVICE),

That attribute is being set today, but it is only in the NameResolver attributes, not in the EAG:

childSwitchLb.handleResolvedAddresses(
resolvedAddresses.toBuilder()
.setAttributes(attributes.toBuilder()
.set(NameResolver.ATTR_BACKEND_SERVICE, cluster)
.build())
.setLoadBalancingPolicyConfig(config.childConfig)
.build());

(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.)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions