Skip to content

Add per-plugin workload counters#13278

Open
moonchen wants to merge 5 commits into
apache:masterfrom
moonchen:per-plugin-cpu-metrics
Open

Add per-plugin workload counters#13278
moonchen wants to merge 5 commits into
apache:masterfrom
moonchen:per-plugin-cpu-metrics

Conversation

@moonchen

Copy link
Copy Markdown
Contributor

Add per-plugin metrics that allow us to track how much work each plugin is doing by counting their invocations, intercept bytes, and intercept transfers.

Add proxy.process.plugin..{invocations,bytes, transfers}, keyed by the plugin DSO basename and bounded by the number of loaded plugins.

Global plugins load via raw dlopen and previously carried no identity, so they are given a PluginThreadContext around TSPluginInit; the continuations they create then carry plugin identity the same way remap plugins already do.

Copilot AI review requested due to automatic review settings June 15, 2026 21:28
@moonchen moonchen self-assigned this Jun 15, 2026

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 per-plugin workload metrics to Apache Traffic Server so operators can attribute plugin activity to specific plugin DSOs (by basename), covering callback invocations as well as PluginVC intercept transport bytes/transfers. It also adds a gold test to validate that the new counters increment for both global and remap plugins.

Changes:

  • Add proxy.process.plugin.<name>.{invocations,bytes,transfers} counters and increment them from key dispatch / transport paths.
  • Introduce a PluginThreadContext wrapper for global plugins so continuations they create carry plugin identity (similar to remap plugins).
  • Add a gold test that drives traffic through a global plugin, a remap plugin, and a PluginVC intercept plugin and asserts the counters are non-zero.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/gold_tests/pluginTest/per_plugin_metrics/rules/global.conf Adds a header_rewrite rule to ensure global-plugin continuation dispatch occurs per transaction.
tests/gold_tests/pluginTest/per_plugin_metrics/per_plugin_metrics.test.py New gold test validating per-plugin invocation/bytes/transfers metrics via traffic_ctl metric get.
src/proxy/PluginVC.cc Increments per-plugin bytes/transfers counters for PluginVC intercept data movement and captures counters at core allocation time.
include/proxy/PluginVC.h Stores per-plugin counter pointers in PluginVCCore for intercept accounting.
src/proxy/Plugin.cc Wraps global plugin initialization in a PluginThreadContext so created continuations carry plugin identity.
src/proxy/http/remap/RemapPlugins.cc Counts remap plugin invocations at the remap dispatch site.
include/proxy/http/remap/PluginDso.h Adds metric registration/increment helpers and per-plugin counter pointers to PluginThreadContext.
src/proxy/http/remap/PluginDso.cc Implements metric-name tokenization and registers per-plugin counters on successful plugin load.
src/api/InkContInternal.cc Counts per-plugin invocations for TSCont (continuation) callback dispatches.

Comment thread src/proxy/http/remap/PluginDso.cc Outdated
Comment thread src/api/InkContInternal.cc Outdated
@moonchen moonchen added this to the 10.2.0 milestone Jun 15, 2026
Add per-plugin metrics that allow us to track how much work each plugin is doing
by counting their invocations, intercept bytes, and intercept transfers.

Add proxy.process.plugin.<name>.{invocations,bytes, transfers}, keyed by the
plugin DSO basename and bounded by the number of loaded plugins.

Global plugins load via raw dlopen and previously carried no identity, so they
are given a PluginThreadContext around TSPluginInit; the continuations they
create then carry plugin identity the same way remap plugins already do.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@moonchen moonchen force-pushed the per-plugin-cpu-metrics branch from 2d9c816 to a36b73c Compare June 15, 2026 21:52
@cmcfarlen cmcfarlen modified the milestones: 10.2.0, 11.0.0 Jun 15, 2026
@cmcfarlen cmcfarlen requested a review from bneradt June 15, 2026 22:08
@moonchen

Copy link
Copy Markdown
Contributor Author

[approve ci autest]

@moonchen

Copy link
Copy Markdown
Contributor Author

[approve ci osx]

@moonchen

Copy link
Copy Markdown
Contributor Author

[approve ci rocky]

1 similar comment
@moonchen

Copy link
Copy Markdown
Contributor Author

[approve ci rocky]

The per-plugin metrics change pulls the real IPAllow.o into test_proxy
(Plugin.o now references PluginDso's registerPluginMetrics), so the stub
definition of IpAllow::subjects duplicated the real one and tripped
AddressSanitizer's ODR check on the Rocky (ASAN) build. Drop the stub;
the linked IPAllow.o now provides the symbol.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 18, 2026 21:55

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

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Comment thread src/proxy/PluginVC.cc Outdated
moonchen and others added 2 commits June 18, 2026 18:03
regex_revalidate and lua gold tests diff `traffic_ctl metric match
<name>` against a fixed set, but the new proxy.process.plugin.<name>.*
workload counters also match that substring, adding lines and breaking
the gold compare. Anchor the match to ^plugin.<name>. so it captures
only each plugin's own metrics.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
_transfers was incremented before the other_ntodo / lock-miss /
buffer-space early returns, so write-side passes that moved zero bytes
were counted. Move the increment after transfer_bytes and gate it on a
positive byte count, matching the _bytes counter.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 18, 2026 23:42

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

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.

Comment thread src/proxy/Plugin.cc
GlobalPluginContext in Plugin.cc (ts::proxy) called the out-of-line
PluginThreadContext::registerPluginMetrics() defined in PluginDso.cc
(ts::http_remap), adding a ts::proxy -> ts::http_remap link dependency.
Move the implementation (and its token helper) into the header so the
symbol is resolved locally and the cross-library edge goes away.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@moonchen

Copy link
Copy Markdown
Contributor Author

[approve ci autest]

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

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants