class ExceptionSubscriber in New Relic 8
Same name and namespace in other branches
- 2.x src/EventSubscriber/ExceptionSubscriber.php \Drupal\new_relic_rpm\EventSubscriber\ExceptionSubscriber
- 2.0.x src/EventSubscriber/ExceptionSubscriber.php \Drupal\new_relic_rpm\EventSubscriber\ExceptionSubscriber
Provides a way to send Exceptions to the New Relic API.
Hierarchy
- class \Drupal\new_relic_rpm\EventSubscriber\ExceptionSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of ExceptionSubscriber
1 string reference to 'ExceptionSubscriber'
1 service uses ExceptionSubscriber
File
- src/
EventSubscriber/ ExceptionSubscriber.php, line 14
Namespace
Drupal\new_relic_rpm\EventSubscriberView source
class ExceptionSubscriber implements EventSubscriberInterface {
/**
* New Relic adapter.
*
* @var \Drupal\new_relic_rpm\ExtensionAdapter\NewRelicAdapterInterface
*/
protected $adapter;
/**
* Constructs a subscriber.
*
* @param \Drupal\new_relic_rpm\ExtensionAdapter\NewRelicAdapterInterface $adapter
* The Adapter to use when talking to the New Relic extension.
*/
public function __construct(NewRelicAdapterInterface $adapter) {
$this->adapter = $adapter;
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
// Ensure this runs just before FinalExceptionSubscriber.
$events[KernelEvents::EXCEPTION][] = [
'onException',
-255,
];
return $events;
}
/**
* Handles errors for this subscriber.
*
* @param \Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event
* The event to process.
*/
public function onException(GetResponseForExceptionEvent $event) {
// Don't log http exceptions.
if ($event
->getException() instanceof HttpExceptionInterface) {
return;
}
if (\Drupal::config('new_relic_rpm.settings')
->get('override_exception_handler')) {
// Forward the exception to New Relic.
$this->adapter
->logException($event
->getException());
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ExceptionSubscriber:: |
protected | property | New Relic adapter. | |
ExceptionSubscriber:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | |
ExceptionSubscriber:: |
public | function | Handles errors for this subscriber. | |
ExceptionSubscriber:: |
public | function | Constructs a subscriber. |