Developer stats & metrics
This guide is for DeskFlow developers who want visibility into API usage — slow task.list calls, OPcache hit rate, and framework health at /stats on port 8000.
What you will learn
- How to open
/statsand/stats.jsonwith a token whenDEBUG=false - What
php pionia stats:viewprints fromstorage/metrics/requests.jsonl - How OPcache snapshots feed Production performance
- DeskFlow running (
php pionia serveorrunserver) - Familiarity with Logging — complementary, not a replacement
How it works
Pionia records per-request metrics for Moonlight API calls and exposes them through a web dashboard and CLI.
Web dashboard
| URL | Format |
|---|---|
/stats | HTML health dashboard |
/stats.json | Same data as JSON |
Enabled when DEBUG=true by default, or explicitly:
# environment/settings.ini
STATS_ENABLED = true# environment/.env — generate your own token; never commit a shared docs example
STATS_TOKEN=Generate a token locally (Security utilities):
php pionia shellsecure_random_hex(32); // paste into STATS_TOKEN= in environment/.env
Access the dashboard with ?token=<your-token> or header X-Stats-Token: <your-token>.
Lock down production
Disable stats in production or require a strong STATS_TOKEN. Do not leave /stats open without authentication when DEBUG=false.
CLI snapshot
php pionia stats:view # human-readable table
php pionia stats:view --json # JSON export
php pionia stats:view --reset # clear storage/metrics/requests.jsonlAliases: stats, viewstats.
Disabling writes
To stop writing metrics while keeping the stats page:
[metrics]
ENABLED = falseWhat is collected
- Request count, average duration, slow endpoints
- Grouping by service/action where applicable
- Framework static assets (
/__pionia/*) are excluded - OPcache — hit rate, cached scripts, preload memory, JIT status
- Framework version — resolved from installed
pionia/pionia-coreComposer package
When [performance] RECORD_OPCACHE_SNAPSHOT=true, workers also write storage/metrics/opcache-snapshot.json for stats-driven preload generation (see Production performance).
Common mistakes
- Leaving
/statspublic in production — setSTATS_TOKENor disable withSTATS_ENABLED=false. - Using stats as audit logging — metrics are aggregated; use Logging for per-request detail.
- Resetting metrics during an investigation —
stats:view --resetclears history; export with--jsonfirst. - Expecting static asset hits in API metrics —
/__pionia/*routes are excluded from Moonlight grouping.
What’s next
Production performance
optimize --production and preload.
Logging
logger(), report(), storage/logs/.
HTTP routing
Bootstrap route cache.