rate_limit: fix swapped metric tag and prefix in YAML configs - #13601
Open
sinhaparth5 wants to merge 1 commit into
Open
rate_limit: fix swapped metric tag and prefix in YAML configs#13601sinhaparth5 wants to merge 1 commit into
sinhaparth5 wants to merge 1 commit into
Conversation
initializeMetrics() takes the tag before the prefix, and the remap path passes them in that order, but the YAML path had them reversed. Every SNI limiter with a metrics node was named tag.sni.prefix instead of prefix.sni.tag, including when only one of the keys was set and the other came from its default. Fixes: apache#13599
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes rate_limit YAML metrics naming by correcting the argument order passed to RateLimiter::initializeMetrics() so metrics are consistently generated as prefix.type.tag (matching the remap path and the metric helper’s concatenation order).
Changes:
- Fix swapped
(prefix, tag)→(tag, prefix)when initializing metrics for YAML-defined SNI limiters. - Improve the related debug log line to label
prefixandtagexplicitly. - Add a new gold test that asserts correct metric names for YAML configurations with: both keys set, only
tagset, and onlyprefixset.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
plugins/experimental/rate_limit/limiter.h |
Corrects YAML metrics initialization to pass (tag, prefix) into initializeMetrics() so metric names are built in the intended order. |
tests/gold_tests/pluginTest/rate_limit/rate_limit_metric_names.test.py |
Adds an autest that validates metric naming for all relevant YAML metrics node shapes and guards against regressions. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
RateLimiter::initializeMetrics()takes the tag before the prefix:The remap path passes them in that order (
txn_limiter.cc:182), but the YAMLpath passed
(prefix, tag).metric_helper()builds the name asprefix + "." + type + "." + tag, so every SNI limiter with ametricsnodecame out as
tag.sni.prefix.This affects a
metricsnode even when only one of the two keys is set, sincethe unset one takes its default and the two get swapped together.
Testing
New autest
rate_limit_metric_namescovers all three shapes: both keys set,only
tagset, and onlyprefixset.Run against the plugin built without this change,
traffic_ctl metric matchreports the reversed names, which is what the test now pins:
All 7 rate_limit autests pass with the change.
Fixes: #13599