stats: migrate the simple scope creation to new API#45913
Open
wbpcode wants to merge 1 commit into
Open
Conversation
Signed-off-by: wbpcode/wangbaiping <wbphub@gmail.com>
Contributor
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. |
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)); |
Member
Author
There was a problem hiding this comment.
This will be addressed at #45846. And this PR only core the API's migration and assume the API implementation correctly processed everything.
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 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.