Skip to content

stats: migrate the simple scope creation to new API#45913

Open
wbpcode wants to merge 1 commit into
envoyproxy:mainfrom
wbpcode:dev-imigrate-to-new-stats-api-3
Open

stats: migrate the simple scope creation to new API#45913
wbpcode wants to merge 1 commit into
envoyproxy:mainfrom
wbpcode:dev-imigrate-to-new-stats-api-3

Conversation

@wbpcode

@wbpcode wbpcode commented Jul 1, 2026

Copy link
Copy Markdown
Member

Commit Message: stats: migrate the simple scope creation to new 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>

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 call sites that create “simple” stats scopes from the legacy createScope(...) API to the newer createScopeWithTaggedName(...) API, preparing Envoy for a tags/labels-friendly stats system while preserving legacy behavior until the new API is explicitly enabled.

Changes:

  • Update MockScope and impacted unit tests to reflect the new “base_name + tagged_name” scope-creation signature.
  • Migrate multiple production scope creation sites (upstream clusters, tcp_proxy, gRPC async client, SDS, listener manager, redis proxy) to supply well-known tag keys alongside an explicit flat (legacy) tagged name.
  • Add required build dependencies for well_known_names.h where newly included.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/mocks/stats/mocks.h Adjust mock scope helpers to forward both base and tagged scope names.
test/extensions/access_loggers/stats/stats_test.cc Update expectations/lambdas for the new createScope_ mock signature.
test/extensions/access_loggers/stats/scope_provider_singleton_test.cc Update expectations/lambdas for the new createScope_ mock signature.
test/common/grpc/async_client_manager_impl_test.cc Update expectations to match new (base_name, tagged_name) scope creation.
source/extensions/filters/network/redis_proxy/config.cc Create redis cluster scopes via createScopeWithTaggedName with envoy.cluster_name.
source/extensions/filters/network/redis_proxy/BUILD Add dependency for //source/common/config:well_known_names.
source/common/upstream/upstream_impl.cc Create cluster scopes via createScopeWithTaggedName with envoy.cluster_name.
source/common/tcp_proxy/tcp_proxy.cc Create tcp proxy scopes via createScopeWithTaggedName with envoy.tcp_prefix.
source/common/secret/sds_api.cc Create SDS scopes via createScopeWithTaggedName with envoy.xds_resource_name.
source/common/secret/BUILD Add dependency for //source/common/config:well_known_names.
source/common/listener_manager/listener_impl.cc Create listener scopes via createScopeWithTaggedName with envoy.listener_address.
source/common/grpc/BUILD Add dependency for //source/common/config:well_known_names.
source/common/grpc/async_client_manager_impl.cc Create gRPC scopes via createScopeWithTaggedName with envoy.google_grpc_client_prefix.

Comment on lines +299 to +303
// TODO(wbpcode): for the 'admin' listener, we won't extract the listener address as a tag.
listener_scope = stats.createScopeWithTaggedName(
"listener",
{Stats::TagStringView{Config::TagNames::get().LISTENER_ADDRESS, observability_name}},
fmt::format("listener.{}.", observability_name), false, {}, std::move(scope_matcher));

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This will be addressed at #45846. And this PR only core the API's migration and assume the API implementation correctly processed everything.

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.

4 participants