Skip to content

Commit a22b31b

Browse files
committed
Implement plugin for handled exceptions
1 parent a9d408e commit a22b31b

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\NewRelicReporting\Plugin;
7+
8+
use Magento\Framework\App\Http;
9+
use Magento\NewRelicReporting\Model\Config;
10+
use Magento\NewRelicReporting\Model\NewRelicWrapper;
11+
12+
class HttpPlugin
13+
{
14+
/**
15+
* @var Config
16+
*/
17+
protected $config;
18+
19+
/**
20+
* @var NewRelicWrapper
21+
*/
22+
protected $newRelicWrapper;
23+
24+
/**
25+
* @param Config $config
26+
* @param NewRelicWrapper $newRelicWrapper
27+
*/
28+
public function __construct(
29+
Config $config,
30+
NewRelicWrapper $newRelicWrapper
31+
) {
32+
$this->config = $config;
33+
$this->newRelicWrapper = $newRelicWrapper;
34+
}
35+
36+
public function beforeCatchException(Http $subject, $bootstrap, $exception)
37+
{
38+
if ($this->config->isNewRelicEnabled()) {
39+
$this->newRelicWrapper->reportError($exception);
40+
}
41+
}
42+
}

app/code/Magento/NewRelicReporting/etc/di.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,7 @@
2727
</argument>
2828
</arguments>
2929
</type>
30+
<type name="Magento\Framework\App\Http">
31+
<plugin name="framework-http-newrelic" type="Magento\NewRelicReporting\Plugin\HttpPlugin"/>
32+
</type>
3033
</config>

0 commit comments

Comments
 (0)