Skip to content
Lukman Nakib edited this page May 30, 2026 · 1 revision

Tracer

Core\Tracer records, in order, each of the plugin's own Hook and Route firings during a request — with timing and memory — so you can debug sequencing and measure performance. It's off by default and adds zero overhead when off.

Enable it

add_filter('wppm/trace_enabled', '__return_true');   // default: WP_DEBUG

The gate is evaluated once at boot. When off, the Hook/Router resolvers return the raw callable verbatim — no wrapping, no microtime, no allocation. When on, each plugin callable is decorated to record a flat trace entry:

{ name, type (action|filter|rest|ajax), callback, order, duration_ms, mem_delta, priority }

Filters stay transparent (the wrapper returns the filtered value unchanged); the AJAX wrap sits inside the existing nonce → method → capability gate.

Inspect it

A read-only Tracer admin page (wp-plugin-matrix-tracer, capability manage_options) renders the current request's trace as a table — the page traces its own load. Optionally persist the last trace:

add_filter('wppm/trace_dump', '__return_true');  // on shutdown, store the last trace in a transient + log

Scope

The Tracer wraps only your plugin's registrations (everything routed through Core\Hook and Core\Router) — it deliberately ignores WordPress's global all action, which keeps it cheap.

Design: docs/adr/0007-execution-tracer-wraps-hook-router-seams.md. v1 is a flat ordered list (no span tree, no REST API, no ring buffer) and does not catch/alter thrown callables.

Clone this wiki locally