TraceHawk // browser and PHP errors Group · Count · File the ticket Ingest operational

Symfony

Symfony exception monitoring.

Register one bundle. It reports uncaught HTTP exceptions, console errors, and each web request from TRACEHAWK_DSN.

What it does

TraceHawkBundle subscribes to the kernel and the console. On the main request it starts a trace. On terminate it sends the method and path. An exception that is not an HTTP exception below status 500 is captured. A 404 is not sent. A console error is sent. A normal console command is not reported as an HTTP request.

The listener reads TRACEHAWK_DSN, then TRACEX_DSN. The environment comes from APP_ENV, or prod when that value is missing. If TraceHawk is unreachable, the report gives up in under half a second.

Install

composer config repositories.tracehawk composer https://tracehawk.net/sdk
composer require tracehawk/sdk:1.1.0
TRACEHAWK_DSN=https://tracehawk.net/api/<key>
# config/bundles.php
TraceHawk\Sdk\Symfony\TraceHawkBundle::class => ['all' => true],

Symfony Flex will not discover this package from Packagist. The line above is the whole registration. The bundle does not ship a configuration file.

Release, user, and a handled exception

The bundle does not read a release from the container. Set it once the client has initialized, which the listener does on the first kernel or console event. A practical place is a listener of your own on kernel.request with a later priority, or immediately before a capture.

use TraceHawk\Sdk\TraceHawk;

TraceHawk::setRelease('app@1.4.2');
TraceHawk::setUser($userId);
TraceHawk::addBreadcrumb('checkout', 'Card step opened');

try {
    $order->charge();
} catch (\Throwable $e) {
    TraceHawk::capture($e);
    throw $e;
}

Supported features

The Symfony bundle does not attach SQL, HTTP client, or cache spans. That collector is part of the Laravel provider. You can still call TraceHawk::addSpan yourself.

Troubleshooting

Questions

Does a Symfony 404 open an issue?

No. The listener skips HTTP exceptions whose status is below 500.

Where does the DSN come from?

The environment variable TRACEHAWK_DSN. TRACEX_DSN is still read if the first name is empty. There is no Symfony config tree for the bundle.

Are console commands reported?

A command that finishes normally is not sent as a request. An error during the command is captured.

Related

Ready to turn error noise into actionable issues?