Skip to content

stats: migrate some network filters to use new stats API#45915

Open
wbpcode wants to merge 2 commits into
envoyproxy:mainfrom
wbpcode:dev-imigrate-to-new-stats-api-5
Open

stats: migrate some network filters to use new stats API#45915
wbpcode wants to merge 2 commits into
envoyproxy:mainfrom
wbpcode:dev-imigrate-to-new-stats-api-5

Conversation

@wbpcode

@wbpcode wbpcode commented Jul 1, 2026

Copy link
Copy Markdown
Member

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.

Signed-off-by: wbpcode/wangbaiping <wbphub@gmail.com>
Signed-off-by: wbpcode/wangbaiping <wbphub@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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::TaggedStatNamePrefix plus new Utility::*FromTaggedPrefix helpers and POOL_*_TAGGED macros 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"
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.

2 participants