nipwaayoni/elastic-apm-php-agent
Laravel-friendly Elastic APM PHP agent for instrumenting apps and sending performance data, errors, and transactions to an Elastic APM Server. Helps monitor response times, slow queries, and exceptions with simple setup and configurable reporting.
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 = [
'serviceName' => 'examples',
'serviceVersion' => '1.0.0-beta',
];
$agent = (new \Nipwaayoni\AgentBuilder())
->withConfig(new Nipwaayoni\Config($config))
->build();
// 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?