stats: migrate the simple scope creation to new API#45913
Conversation
Signed-off-by: wbpcode/wangbaiping <wbphub@gmail.com>
There was a problem hiding this comment.
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
MockScopeand 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.hwhere 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. |
|
/retest |
| // grpc.(<stat_prefix>).** | ||
| scope_(scope.createScopeWithTaggedName( | ||
| "grpc", | ||
| {Stats::TagStringView{Envoy::Config::TagNames::get().GOOGLE_GRPC_CLIENT_PREFIX, | ||
| config.google_grpc().stat_prefix()}}, | ||
| fmt::format("grpc.{}.", config.google_grpc().stat_prefix()))), |
There was a problem hiding this comment.
In the legacy mode (default mode for now), for the createScopeWithTaggedName, if the tagged name grpc.<prefix> is provided, it will be used.
It's identical with createScope("grpc.<prefix>").
|
Discussed offline and waiting on some tests that validate that no stat names change. /wait-any |
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.