HttpPlugin.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\NewRelicReporting\Plugin;
  7. use Magento\Framework\App\Bootstrap;
  8. use Magento\Framework\App\Http;
  9. use Magento\NewRelicReporting\Model\Config;
  10. use Magento\NewRelicReporting\Model\NewRelicWrapper;
  11. class HttpPlugin
  12. {
  13. /**
  14. * @var Config
  15. */
  16. private $config;
  17. /**
  18. * @var NewRelicWrapper
  19. */
  20. private $newRelicWrapper;
  21. /**
  22. * @param Config $config
  23. * @param NewRelicWrapper $newRelicWrapper
  24. */
  25. public function __construct(
  26. Config $config,
  27. NewRelicWrapper $newRelicWrapper
  28. ) {
  29. $this->config = $config;
  30. $this->newRelicWrapper = $newRelicWrapper;
  31. }
  32. /**
  33. * Report exception to New Relic
  34. *
  35. * @param Http $subject
  36. * @param Bootstrap $bootstrap
  37. * @param \Exception $exception
  38. * @return void
  39. *
  40. * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  41. */
  42. public function beforeCatchException(Http $subject, Bootstrap $bootstrap, \Exception $exception)
  43. {
  44. if ($this->config->isNewRelicEnabled()) {
  45. $this->newRelicWrapper->reportError($exception);
  46. }
  47. }
  48. }