stats: migrate some network filters to use new stats API#45915
Open
wbpcode wants to merge 2 commits into
Open
Conversation
Signed-off-by: wbpcode/wangbaiping <wbphub@gmail.com>
Signed-off-by: wbpcode/wangbaiping <wbphub@gmail.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR migrates several network/UDP filters from string-based stat construction to a new tagged-stat creation path, introducing reusable helpers and macros to pre-encode prefixes/tags for efficient stat instantiation while preserving legacy behavior until the tag-aware API is enabled.
Changes:
- Add
Stats::TaggedStatNamePrefixplus newUtility::*FromTaggedPrefixhelpers andPOOL_*_TAGGEDmacros to create tagged stats without allocating per-owner sub-scopes. - Update UDP proxy, DNS filter, and multiple network/listener rate-limit/connection-limit filters to use the new tagged-prefix API and well-known tag names.
- Add unit test coverage for the new tagged-prefix helper behavior (flat-name composition).
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test/common/stats/utility_test.cc | Adds a new test validating flat-name composition for tagged-prefix stat helpers. |
| source/extensions/filters/udp/udp_proxy/config.h | Migrates UDP proxy downstream stats creation to tagged-prefix API. |
| source/extensions/filters/udp/udp_proxy/BUILD | Adds deps needed for tagged-prefix stats and well-known tag names. |
| source/extensions/filters/udp/dns_filter/dns_filter.h | Migrates DNS filter stats creation to tagged-prefix API. |
| source/extensions/filters/udp/dns_filter/BUILD | Adds deps needed for tagged-prefix stats and well-known tag names. |
| source/extensions/filters/network/ratelimit/ratelimit.cc | Migrates TCP ratelimit filter stats to tagged-prefix API. |
| source/extensions/filters/network/ratelimit/BUILD | Adds deps needed for tagged-prefix stats and well-known tag names. |
| source/extensions/filters/network/local_ratelimit/local_ratelimit.cc | Migrates network local ratelimit stats to tagged-prefix API. |
| source/extensions/filters/network/local_ratelimit/BUILD | Adds deps needed for tagged-prefix stats and well-known tag names. |
| source/extensions/filters/network/connection_limit/connection_limit.cc | Migrates connection limit stats to tagged-prefix API. |
| source/extensions/filters/network/connection_limit/BUILD | Adds deps needed for tagged-prefix stats and well-known tag names. |
| source/extensions/filters/listener/local_ratelimit/local_ratelimit.cc | Migrates listener local ratelimit stats to tagged-prefix API. |
| source/extensions/filters/listener/local_ratelimit/BUILD | Adds deps needed for tagged-prefix stats and well-known tag names. |
| source/common/stats/utility.h | Introduces TaggedStatNamePrefix and declares *FromTaggedPrefix helpers. |
| source/common/stats/utility.cc | Implements *FromTaggedPrefix helpers to build tag-extracted + flat stat names. |
| source/common/stats/symbol_table.h | Adds StatNamePool::reserve() to reduce reallocations when pre-encoding names. |
| envoy/stats/stats_macros.h | Adds POOL_*_TAGGED macros to create stats using pre-encoded prefixes/tags. |
Comment on lines
5
to
9
| #include "envoy/filter/config_provider_manager.h" | ||
| #include "envoy/server/filter_config.h" | ||
|
|
||
| #include "source/common/config/well_known_names.h" | ||
| #include "source/extensions/filters/udp/udp_proxy/udp_proxy_filter.h" |
Comment on lines
11
to
15
| #include "source/common/common/radix_tree.h" | ||
| #include "source/common/config/config_provider_impl.h" | ||
| #include "source/common/config/well_known_names.h" | ||
| #include "source/common/network/socket_impl.h" | ||
| #include "source/common/network/utility.h" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Commit Message: stats: migrate some network filters to use new stats API
Additional Description:
Parts of #20289. This migrate the previous stats creation to use new tags-friendly API. But note, before we merge #45846 and enable it explicitly. This won't bring any changes to the final behavior because the legacy mode will ignore the provided tags but only use the flat name.
Risk Level: low.
Testing: unit.
Docs Changes: n/a.
Release Notes: n/a.
Platform Specific Features: n/a.