Skip to content

stats: add tag extraction rule for embedded gRPC client streams_closed stats#44063

Open
Retr0-XD wants to merge 1 commit intoenvoyproxy:mainfrom
Retr0-XD:fix/tag-extraction-rules-21595
Open

stats: add tag extraction rule for embedded gRPC client streams_closed stats#44063
Retr0-XD wants to merge 1 commit intoenvoyproxy:mainfrom
Retr0-XD:fix/tag-extraction-rules-21595

Conversation

@Retr0-XD
Copy link

@Retr0-XD Retr0-XD commented Mar 21, 2026

Description

Fixes #21595.

The existing grpc.$.** tokenized rule (added in #36673) covers top-level gRPC stats of the form grpc.<stat_prefix>.*. However, a number of Envoy subsystems embed a gRPC client inside a longer stat path, producing stats like:

listener_manager.lds.grpc.<lds_cluster>.streams_closed_1
sds.client_cert.grpc.<sds_cluster>.streams_closed_12
http.scoped_rds.*.grpc.<srds_cluster>.streams_closed_0

In these cases the stat_prefix appears after .grpc. but the full stat name does not start with grpc., so the tokenized rule never fires. The checkForMissingTagExtractionRules() integration test helper detected these as unextracted stats, which caused 9 test files to disable that check with skip_tag_extraction_rule_check_ = true guarded by a TODO(ggreenway) comment.

Changes

source/common/config/well_known_names.cc — add one new regex rule after the existing tokenized grpc.$.** rule:

// [*.]grpc.(<stat_prefix>.)streams_closed_<gRPC_status_code>
// Handles gRPC client stats where the stat_prefix is embedded inside a longer
// stat name (e.g. listener_manager.lds.grpc.(<lds_cluster>.)streams_closed_1,
// sds.client_cert.grpc.(<sds_cluster>.)streams_closed_12).
addRe2(GOOGLE_GRPC_CLIENT_PREFIX, R"(\.grpc\.((.+)\.streams_closed_\d+)$)", ".grpc.");

The regex anchors on .grpc. (using the substr hint for RE2 performance), captures everything between .grpc. and .streams_closed_<N> as the removed portion, and the inner group ((.+)) becomes the tag value.

9 test files — remove all 11 skip_tag_extraction_rule_check_ = true TODO blocks:

Test file Stat pattern unblocked
tcp_grpc_access_log_integration_test.cc grpc.accesslog.streams_closed_N
http_grpc_access_log_integration_test.cc grpc.accesslog.streams_closed_N
metrics_service_integration_test.cc grpc.metrics_service.streams_closed_N
ratelimit_integration_test.cc grpc.<cluster>.streams_closed_N
listener_lds_integration_test.cc (×2) listener_manager.lds.grpc.<lds>.streams_closed_N
listener_extension_discovery_integration_test.cc *.grpc.<ecds>.streams_closed_N
extension_discovery_integration_test.cc *.grpc.<lds>.streams_closed_N
scoped_rds.h http.scoped_rds.*.grpc.<srds>.streams_closed_N
sds_dynamic_integration_test.cc (×2) sds.*.grpc.<sds_cluster>.streams_closed_N

Testing

The checkForMissingTagExtractionRules() mechanism in test/integration/base_integration_test.cc queries the Envoy admin API, collects all stat_prefix values from the active config, and asserts that none of them appear verbatim in the tag-extracted stat names. Removing the skip_tag_extraction_rule_check_ guards re-enables this check in all 9 integration tests.

AI Disclosure: Used GitHub Copilot for coding assistance.

AI disclosure: GitHub Copilot was used during implementation and test writing. I fully understand all changes made in this PR.

Commit Message: See PR title
Risk Level: Low
Testing: Unit tests added/verified
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

@repokitteh-read-only
Copy link

Hi @Retr0-XD, welcome and thank you for your contribution.

We will try to review your Pull Request as quickly as possible.

In the meantime, please take a look at the contribution guidelines if you have not done so already.

🐱

Caused by: #44063 was opened by Retr0-XD.

see: more, trace.

Fixes envoyproxy#21595.

Add a regex rule in well_known_names.cc to extract the gRPC client
stat_prefix from stats where the gRPC client is used via a nested
cluster reference (e.g. listener_manager.lds.grpc.<prefix>.streams_closed_N,
sds.client_cert.grpc.<prefix>.streams_closed_N).

The existing grpc.$.** tokenized rule already covers top-level
grpc.<prefix>.* stats (added in envoyproxy#36673). This new rule handles the
embedded case using a regex that anchors on .grpc. and .streams_closed_N.

Remove all 11 skip_tag_extraction_rule_check_ = true TODO blocks from
9 integration test files that were blocked on these missing rules.

AI Disclosure: Used GitHub Copilot for coding assistance.

Signed-off-by: Retr0-XD <sakthi.harish@edgeverve.com>
@Retr0-XD Retr0-XD force-pushed the fix/tag-extraction-rules-21595 branch from f4773d8 to 02785c7 Compare March 22, 2026 06:17
@Retr0-XD Retr0-XD requested a deployment to external-contributors March 22, 2026 06:17 — with GitHub Actions Waiting
@Retr0-XD
Copy link
Author

Added jitter support for HTTP max_connection_duration to prevent thundering herd during connection drains. Detailed comments in the PR. Would appreciate your review when available.

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.

Tag extraction rules missing for many stats

1 participant