Database transactions
Flare can collect information about the database transactions being executed in your application. This includes:
- Whether the transaction was committed or rolled back
This functionality is enabled by default, but you can disable it by calling ignoreTransactions()
on the Flare config:
$config->ignoreTransactions();
You can configure the maximum number of transactions tracked while collecting data in the case of an error as such:
$config->collectTransactions(maxItemsWithErrors: 10);
Collecting transactions
We cannot automatically collect transactions in the framework-agnostic version of the package. You can manually add transactions as such:
$flare->transaction()->recordBegin();
// Do your transaction
$flare->transaction()->recordCommit();
In the case of a rollback, you can call the recordRollback
method:
$flare->transaction()->recordBegin();
// Do your transaction
$flare->transaction()->recordRollback();
It is always possible to add extra attributes to the transaction:
$flare->transaction()->recordBegin(
attributes: [
'database.connection' => 'mysql',
]
);
Or when committing:
$flare->transaction()->recordCommit(
attributes: [
'database.connection' => 'mysql',
]
);
Or when rolling back:
$flare->transaction()->recordRollback(
attributes: [
'database.connection' => 'mysql',
]
);
- On this page
- Collecting transactions