File tree Expand file tree Collapse file tree 3 files changed +69
-0
lines changed
app/code/Magento/NewRelicReporting Expand file tree Collapse file tree 3 files changed +69
-0
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,19 @@ public function addCustomParameter($param, $value)
2828 return false ;
2929 }
3030
31+ /**
32+ * Wrapper for 'newrelic_notice_error' function
33+ *
34+ * @param Exception $exception
35+ * @return void
36+ */
37+ public function reportError ($ exception )
38+ {
39+ if (extension_loaded ('newrelic ' )) {
40+ newrelic_notice_error ($ exception ->getMessage (), $ exception );
41+ }
42+ }
43+
3144 /**
3245 * Checks whether newrelic-php5 agent is installed
3346 *
Original file line number Diff line number Diff line change 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 \Bootstrap ;
9+ use Magento \Framework \App \Http ;
10+ use Magento \NewRelicReporting \Model \Config ;
11+ use Magento \NewRelicReporting \Model \NewRelicWrapper ;
12+
13+ class HttpPlugin
14+ {
15+ /**
16+ * @var Config
17+ */
18+ private $ config ;
19+
20+ /**
21+ * @var NewRelicWrapper
22+ */
23+ private $ newRelicWrapper ;
24+
25+ /**
26+ * @param Config $config
27+ * @param NewRelicWrapper $newRelicWrapper
28+ */
29+ public function __construct (
30+ Config $ config ,
31+ NewRelicWrapper $ newRelicWrapper
32+ ) {
33+ $ this ->config = $ config ;
34+ $ this ->newRelicWrapper = $ newRelicWrapper ;
35+ }
36+
37+ /**
38+ * Report exception to New Relic
39+ *
40+ * @param Http $subject
41+ * @param Bootstrap $bootstrap
42+ * @param \Exception $exception
43+ * @return void
44+ *
45+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
46+ */
47+ public function beforeCatchException (Http $ subject , Bootstrap $ bootstrap , \Exception $ exception )
48+ {
49+ if ($ this ->config ->isNewRelicEnabled ()) {
50+ $ this ->newRelicWrapper ->reportError ($ exception );
51+ }
52+ }
53+ }
Original file line number Diff line number Diff line change 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 >
You can’t perform that action at this time.
0 commit comments