philkra/elastic-apm-php-agent
PHP agent for Elastic APM that instruments your application to capture transactions, spans, errors, and performance metrics. Sends telemetry to Elastic APM Server for tracing and monitoring, with support for web and CLI workloads and configurable sampling.
The agent can capture all types or errors and exceptions that are implemented from the interface Throwable. When capturing an error, you can a context and highly recommended a parent transaction as illustrated in the following snippet.
By doing so you increase the tracability of the error.
// Setup Agent
$config = [
'appName' => 'examples',
'appVersion' => '1.0.0-beta',
];
$agent = new Agent($config);
// start a new transaction or use an existing one
$transaction = $agent->startTransaction('Failing-Transaction');
try {
//
// do stuff that generates an Exception
//
}
catch(Exception $e) {
$agent->captureThrowable($e, [], $transaction);
// handle Exception ..
}
// do some more stuff ..
$agent->stopTransaction($transaction->getTransactionName());
How can I help you explore Laravel packages today?