Skip to content

feat: add the missing xds.authority label #12018

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

AgraVator
Copy link
Contributor

@AgraVator AgraVator commented Apr 14, 2025

This aims to complete the XDS client metrics by adding the remaining grpc.xds.authority metric.

Copy link
Contributor

@kannanjgithub kannanjgithub left a comment

Choose a reason for hiding this comment

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

Review comments.

…a as in the existing flow

2. xds: modifies existing tests to account for authority
Copy link
Member

@ejona86 ejona86 left a comment

Choose a reason for hiding this comment

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

The commit/PR needs more context. Notably, it should include a reference to A78.

@@ -143,7 +143,13 @@ void reportCallbackMetrics(BatchRecorder recorder, XdsClient xdsClient) {
Map<XdsResourceType<?>, Map<String, ResourceMetadata>> metadataByType =
getResourceMetadataCompleted.get(10, TimeUnit.SECONDS);

computeAndReportResourceCounts(metadataByType, callback);
ListenableFuture<Map<XdsResourceType<?>, Map<String, String>>>
getResourceAuthorityCompleted = xdsClient.getSubscribedResourcesAuthoritySnapshot();
Copy link
Member

Choose a reason for hiding this comment

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

This fixes the data race, but there's still a regular race. The two snapshots may not contain all the same types/resources. We need to either pass the authorities through an existing flow or re-compute it from the resource name.

getResourceAuthorityCompleted = xdsClient.getSubscribedResourcesAuthoritySnapshot();

Map<XdsResourceType<?>, Map<String, String>> authorityByType =
getResourceAuthorityCompleted.get(10, TimeUnit.SECONDS);
Copy link
Member

Choose a reason for hiding this comment

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

When using futures, you'd want to start the operations and only then wait for the completions. That way you only pay the latency cost once.

String cacheState = cacheStateFromResourceStatus(metadata.getStatus(), metadata.isCached());
resourceCountsByState.compute(cacheState, (k, v) -> (v == null) ? 1 : v + 1);
authorityByState.put(cacheState, authorityByType.get(type).get(resourceName));
Copy link
Member

Choose a reason for hiding this comment

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

This just randomly assigns authorities to cache states. Authority is another dimension.

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.

3 participants