header_rewrite: count operators and conditions run#13286
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds process metrics to quantify how much work the header_rewrite plugin performs by counting how many operators are executed and conditions are evaluated. It also extends the AuTest replay harness to validate these metrics in gold tests.
Changes:
- Add
proxy.process.plugin.header_rewrite.{operators,conditions}stats and increment them on each operator/condition execution. - Initialize the stats from both global plugin init (
TSPluginInit) and remap init (TSRemapInit). - Extend
ATSReplayTestto support metric checks with a minimum threshold and add a gold test that asserts the new metrics are non-zero.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/gold_tests/pluginTest/header_rewrite/header_rewrite_bundle.replay.yaml | Adds metric checks ensuring the new header_rewrite counters are incrementing. |
| tests/gold_tests/autest-site/ats_replay.test.ext | Extends metric check handling to support min thresholds (but currently contains an awk field bug). |
| plugins/header_rewrite/statement.h | Declares global stat IDs and an initialization helper for work stats. |
| plugins/header_rewrite/statement.cc | Defines the stat IDs and creates the new stats. |
| plugins/header_rewrite/operator.h | Increments the operator-executed metric per operator execution. |
| plugins/header_rewrite/condition.h | Increments the condition-evaluated metric per condition evaluation. |
| plugins/header_rewrite/header_rewrite.cc | Calls stats initialization during plugin init and remap init. |
The per-hook invocation count cannot tell a small ruleset from a large one,
so it does not reflect how much work header_rewrite does per transaction.
Add proxy.process.plugin.header_rewrite.{operators,conditions}, incremented
in the inline Operator::do_exec and Condition::do_eval chain walkers, to make
that workload visible. do_eval short-circuits, so only conditions actually
evaluated are counted. The counters are created once, from both TSPluginInit
and TSRemapInit.
f8d5e48 to
fa731b2
Compare
|
[approve ci autest 0] |
| // createPtr() is idempotent and internally synchronized: it returns the existing counter when | ||
| // one already has the given name. header_rewrite.so can be loaded both globally (TSPluginInit) |
There was a problem hiding this comment.
A reader should infer from the first sentence that createPtr may be invoked twice on the init path for the same metric. It is a justification for omitting a null guard. But there is a null guard, so the comment may cause confusion.
The comment does cover the important fact, which is that the plugin may be loaded as both a global and a remap plugin simultaneously. I think it's not worth rerunning CI to reword in this case, so I'm not requesting a change.
|
[approve ci autest 0] |
JosiahWI
left a comment
There was a problem hiding this comment.
The change has been upgraded to the newer metrics API and includes an AuTest addition for the new metrics. Approving.
Add proxy.process.plugin.header_rewrite.{operators,conditions} to track how much work header_rewrite does. These increment each time an operator or condition is executed.