usage/wordpress-plugin
WordPress plugin
The PHPRay WordPress plugin gives you the application layer of PHPRay on any host — including shared hosting — without the PHP extension. The current version 0.1.9 is a direct download: phpray-wordpress-0.1.9.zip (Plugins → Add New → Upload Plugin). The address /dl/phpray-wordpress.zip always points at the newest release.
What it captures
- per-request timing at the application layer (request start → shutdown hook; does not see time inside C extensions)
- all SQL via the
$wpdbquery log, including N+1 grouping - outbound HTTP via the
http_apifilters (WP_Http) - PHP errors/warnings/notices during the request
- components: every active plugin, theme and core area with inclusive vs self time — this is what makes "which plugin slows down /checkout/" a one-glance answer
- level logic identical to the extension (
smartthresholds,alertnever sampled)
It produces the same JSONL trace record as the extension (trace format) — the collector, dashboard, CLI and PHPRay Cloud consume both without distinction.
Settings
Tools → PHPRay:
- Enabled — the collector can be switched off without deactivating the plugin
- Thresholds — normal/full/alert ms (defaults 200/1000/3000)
- Sample rate — percent of requests that get the deep instrumentation (SQL callers, errors, HTTP calls, per-component breakdown; default 10%)
- Ignore URIs — one prefix per line (e.g.
/wp-cron.php,/feed) - Exclude logged-in admins — skip requests by users with
manage_options - Output mode — see below. Endpoint and Server key apply to
the
collectorandcloudmodes.
Output modes
file— the plugin appends JSONL records towp-content/uploads/phpray/phpray.log(rotated at 10 MB, 3 files kept). A collector on the same box reads that file ([input] jsonl_path = "<path to phpray.log>"incollector.toml) and gives you the local dashboard, the CLI and the Cloud upload. Works with every plugin and collector version.cloud— works from plugin 0.1.1. The plugin talks to PHPRay Cloud directly over the ingest protocol: batches of trace records go tohttps://app.phpray.dev/v1/traces(envelope withbatch_id,sent_at,agent: wp-plugin/0.1.1, every record carrying asite_idderived from thehome_url()host andABSPATH), and per-minute aggregates go to/v1/aggregates, which is what the fleet view, charts and alerts are built from. Paste the server key (prk_…) created in the console. Onlynormal/full/alertrecords are shipped as traces;summaryrequests are counted in the aggregates. Batches are sent at most every 5 s (immediately foralert) after the response has been handed to the web server. The status box in Tools → PHPRay shows the site ID, the last accepted batch, a rejected key (HTTP 401 pauses sending until you change the key and save), the sampling share requested by the console when a site is over quota, and the last error.collector— works from collector 0.15 (plugin 0.1.1). The same envelope is POSTed to the local collector athttp://127.0.0.1:9191/api/v1/ingest(endpoint details). The records then take the collector's normal path: live dashboard, SQLite, CLI, and the Cloud upload when the collector has[cloud]enabled — with the plugin'ssite_id, so the site is the same one the plugin would register incloudmode. Paste a token in Server key only when the collector has an[auth] secret(mint one withphpray token -role user); without a secret the endpoint takes loopback clients only, which is what a plugin on the same box is. Collector 0.14 has no ingest endpoint: with it, keepfilemode.
Limits (honest)
- It is a userland library: it cannot see the PHP core, C extensions, or time spent outside the request lifecycle hooks. The extension sees all of that; the plugin sees the application.
- One plugin per site: it traces the site it is installed in, not other sites on the same account or VPS.
- Component time is attributed from SQL and HTTP callers (the plugin or
theme file that triggered the query or call); it has no per-function
profiler, so
self_msequalsincl_msin the aggregates. - Records are buffered in a WordPress option (200 records, 60 pending
minutes) between batches; on hosts without
fastcgi_finish_request()/litespeed_finish_request()the batch is sent after the page output but before the PHP process ends. - In
smartmode it only profiles the sampled share; the summary layer is always on and cheap (a handful of hooks per request; see Overhead).
Source:
The Polish version is a translation of the English original; parameters and code examples keep their original syntax.
docs-site/docs/usage/wordpress-plugin.md · PHPRay 0.14The Polish version is a translation of the English original; parameters and code examples keep their original syntax.