Errors · Guides
Find slow requests
With performance on, the Laravel SDK measures your requests and queued jobs, and the Performance tab shows which are slow, which run the most queries, and which run one query per row.
Turn it on
Performance is off until you turn it on. Add to .env:
MYBEAST_ERRORS_PERFORMANCE=true
# MYBEAST_ERRORS_PERFORMANCE_SAMPLE_RATE=0.1 the share of ordinary requests and jobs sent
# MYBEAST_ERRORS_PERFORMANCE_SLOW_MS=1000 every one at least this slow is sent tooIt works only while errors are sent, with the URL and the server secret set. With it off, nothing is hooked at all.
What is measured
Every request and queued job is measured. Every failed and every slow one is sent, and a share of the rest (one in ten by default). Each sample has:
- its name: a request by its route,
GET /posts/{post}, never its address; a job by its class, - its duration, its status, how many database queries it ran and how long they took,
- its ten heaviest queries by shape: the SQL with every value taken out, and an
INlist cut to(?), - any N+1: one query shape run 5 times or more, with the line of your code that ran it, such as
app/Http/Controllers/PostController.php:24or the Blade view, - its outgoing HTTP calls, by host. The SDK's own calls to Errors are left out.
A job run on the sync queue inside a request is measured on its own and also counts in the request.
What it costs your app
No request waits for it. Measuring is a few counters per query; a kept sample is written to its own spool after the response has gone out, and the scheduler sends the spool every minute. On a page with 26 queries, measuring added about 0.05 ms to the response at the default share, 0.15 ms with every request kept.
The Performance tab
- Your routes, or your queued jobs, in one environment over a period, ordered by p95 (95 in 100 were faster) or by total time, which finds the fast route called a million times.
- A route's own page: its p50, p95 and max, its p95 and count by hour or day, its N+1 queries, its heaviest queries, its outgoing calls, and its slowest examples kept whole.
Counts are estimates: a sample stands for the share it was drawn from, so a route sent one time in ten counts ten for each sample.
Samples count toward their own monthly limit
MYBEAST_ERRORS_PERFORMANCE_SAMPLE_RATE to send fewer.Fixing an N+1
An N+1 is a query run once per row of an earlier query: a list of 50 posts that loads each post's author on its own runs 51 queries. The finding names the query's shape and the line that ran it. In Laravel the fix is usually eager loading, Post::with('author'), after which the finding stops appearing in new samples.