ErrTapDocs

Laravel SDK

Install errtap/laravel to report exceptions, send structured logs, flag slow and N+1 queries, and monitor queue workers from a Laravel app.

Install and configure

composer require errtap/laravel

The service provider is auto-discovered. Set the DSN in .env:

ERRTAP_DSN=https://et_<key>@<host>/<project>
ERRTAP_ENV=production     # defaults to APP_ENV
ERRTAP_RELEASE=1.4.3      # optional, used for release health and regression detection

Values are read through config('errtap.*'), so they keep working after php artisan config:cache. To edit the config file directly, publish it:

php artisan vendor:publish --tag=errtap-config
VariableDefaultDescription
ERRTAP_DSNnoneURL DSN or bare et_… key. Without it the SDK stays off
ERRTAP_ENDPOINTderived from the DSNIngest URL override; required for a bare key
ERRTAP_ENVAPP_ENV, then productionEnvironment name
ERRTAP_RELEASEnoneRelease identifier
ERRTAP_DB_MONITORtrueReport slow queries and N+1 queries
ERRTAP_SLOW_QUERY_MS500Slow-query threshold in milliseconds
ERRTAP_N1_THRESHOLD10Identical SQL this many times in one request or job counts as N+1
ERRTAP_QUEUE_MONITORtrueSend queue diagnostics to the Queues page
ERRTAP_QUEUE_SAMPLE_RATE1.0Share of successful jobs reported; failures always are
ERRTAP_QUEUE_SNAPSHOT_SECONDS10How often workers snapshot queue depth
ERRTAP_QUEUESnoneExtra queues to snapshot, e.g. redis:emails,default
ERRTAP_QUEUE_CONTROLfalseAllow pause, resume and clear from the dashboard
ERRTAP_QUEUE_CONTROL_TOKENnoneUpload token for queue control

Requires PHP 8.1+ with the curl extension.

Exception reporting

Laravel 11+ (bootstrap/app.php):

use Illuminate\Foundation\Configuration\Exceptions;

->withExceptions(function (Exceptions $exceptions) {
    $exceptions->reportable(
        fn (Throwable $e) => \ErrTap\ErrTap::captureException($e)
    );
})

Laravel 10 and below (App\Exceptions\Handler::register()):

$this->reportable(
    fn (Throwable $e) => \ErrTap\ErrTap::captureException($e)
);

Manual capture and logs

\ErrTap\ErrTap::captureMessage('payment fallback used', [
    'level' => 'warning',
    'tags' => ['flow' => 'checkout'],
]);

\ErrTap\ErrTap::captureException($e, [
    'context' => ['orderId' => $order->id],
    'user' => ['id' => $user->id],
    'fingerprint' => 'checkout-gateway',
]);

\ErrTap\ErrTap::info('checkout started', ['orderId' => $order->id]);
// debug(), warning(), and error() are also available.

Database monitoring

With ERRTAP_DB_MONITOR on, the SDK listens to every query. A query at or above ERRTAP_SLOW_QUERY_MS is reported as a SlowDbQuery warning, and the same SQL run ERRTAP_N1_THRESHOLD or more times in one request or queued job is reported as an NPlusOneQuery warning. Each statement groups into its own issue.

Queue monitoring

Queue workers report job lifecycles (with wait time, duration, CPU and peak memory), queue depth and held ShouldBeUnique locks to the project's Queues page with no extra setup. Data is batched from the worker loop every few seconds and doesn't count toward your event quota. Queue control (pause, resume, clear, move to front, release a lock) is opt-in and authenticated with an upload token. See Queue monitoring.

Delivery

During HTTP requests, events are held and sent after the response has gone out, so a slow or unreachable ErrTap never delays your users. Console commands and queue workers send immediately. Each send has short timeouts, and one flush never holds a worker for more than 5 seconds. Telemetry never throws into your app.

Cron heartbeats

The Laravel package does not export a heartbeat helper. Create a monitor under Cron, copy its generated ping URL, and POST it only after a successful job:

use Illuminate\Support\Facades\Http;

$schedule->command('invoices:generate')->daily()->onSuccess(
    fn () => Http::post(config('services.errtap.invoice_heartbeat_url'))
);

The generated token in that URL authenticates the heartbeat; no DSN header is required.

Release and environment

Set ERRTAP_ENV and ERRTAP_RELEASE before Laravel boots. The service provider passes both to every event and log. Regression detection compares releases you've registered with POST /ingest/release or on the Releases page; see Release tracking.