stats: strip inner custom namespaces in prometheus names#45065
Open
yueshangzuo wants to merge 1 commit into
Open
stats: strip inner custom namespaces in prometheus names#45065yueshangzuo wants to merge 1 commit into
yueshangzuo wants to merge 1 commit into
Conversation
6d90b33 to
8c3fbaf
Compare
The Prometheus formatter only stripped a registered custom stat namespace when it was the leading segment of the tag-extracted name. This worked for listener/root-scoped Wasm custom stats but not for upstream Wasm stats scoped under a cluster, where after tag extraction the namespace ends up in the middle (e.g. `cluster.wasmcustom.foo`), producing names like `envoy_cluster_wasmcustom_foo`. Add `CustomStatNamespaces::stripRegisteredInnerNamespace()` and call it from the Prometheus formatter to strip a registered namespace appearing as a non-leading, non-trailing segment, without hard-coding `wasmcustom` or a specific scope depth. Gated by `envoy.reloadable_features.strip_scoped_custom_stat_namespace` (default true). Signed-off-by: Yueshang zuo <zuoyueshang.zys@alibaba-inc.com>
8c3fbaf to
e2cb747
Compare
Contributor
Author
|
/retest |
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: strip inner custom namespaces in prometheus names
The Prometheus formatter only stripped a registered custom stat namespace when it was the leading segment of the tag-extracted name. This worked for listener/root-scoped Wasm custom stats but not for upstream Wasm stats scoped under a cluster, where after tag extraction the namespace ends up in the middle (e.g.
cluster.wasmcustom.foo), producing names likeenvoy_cluster_wasmcustom_foo.Add
CustomStatNamespaces::stripRegisteredInnerNamespace()and call it from the Prometheus formatter to strip a registered namespace appearing as a non-leading, non-trailing segment, without hard-codingwasmcustomor a specific scope depth. Gated byenvoy.reloadable_features.strip_scoped_custom_stat_namespace(default true).Additional Description:
The existing leading-prefix custom namespace behavior is unchanged. This aligns upstream Wasm custom stats with listener/root-scoped Wasm custom stats and native cluster metrics without hard-coding
wasmcustomor a specific scope depth in the Prometheus formatter.This PR was prepared with assistance from generative AI; the code and behavior were reviewed and tested by the author.
Risk Level:
Medium
Testing:
Added unit coverage for custom namespace inner-segment stripping and Prometheus formatting, including nested scope names, runtime guard disabled behavior, leading-prefix behavior, unregistered namespaces, and full Prometheus text output.
Docs Changes:
N/A
Release Notes:
See changelogs/current.yaml.
Platform Specific Features:
N/A
[Optional Runtime guard:]
envoy.reloadable_features.strip_scoped_custom_stat_namespace
[Optional API Considerations:]
Adds a new pure virtual method
stripRegisteredInnerNamespace()toStats::CustomStatNamespaces. The interface is internal to the stats subsystem and only one production implementation exists (CustomStatNamespacesImpl); no mocks override it, so impact is contained to this PR.