Skip to content

header_rewrite: count operators and conditions run#13286

Open
moonchen wants to merge 1 commit into
apache:masterfrom
moonchen:header-rewrite-work-metrics
Open

header_rewrite: count operators and conditions run#13286
moonchen wants to merge 1 commit into
apache:masterfrom
moonchen:header-rewrite-work-metrics

Conversation

@moonchen

Copy link
Copy Markdown
Contributor

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.

@moonchen moonchen added this to the 11.0.0 milestone Jun 16, 2026
@moonchen moonchen self-assigned this Jun 16, 2026
Copilot AI review requested due to automatic review settings June 16, 2026 21:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ATSReplayTest to 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.

Comment thread tests/gold_tests/autest-site/ats_replay.test.ext
Comment thread plugins/header_rewrite/condition.h
Comment thread plugins/header_rewrite/statement.h Outdated
Comment thread plugins/header_rewrite/statement.cc Outdated
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.
@moonchen moonchen force-pushed the header-rewrite-work-metrics branch from f8d5e48 to fa731b2 Compare June 19, 2026 18:21
@moonchen moonchen requested a review from JosiahWI June 19, 2026 20:19
@moonchen

Copy link
Copy Markdown
Contributor Author

[approve ci autest 0]

Comment on lines +30 to +31
// 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)

@JosiahWI JosiahWI Jun 19, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@moonchen

Copy link
Copy Markdown
Contributor Author

[approve ci autest 0]

@JosiahWI JosiahWI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change has been upgraded to the newer metrics API and includes an AuTest addition for the new metrics. Approving.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants