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)
28
28
return false ;
29
29
}
30
30
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
+
31
44
/**
32
45
* Checks whether newrelic-php5 agent is installed
33
46
*
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 27
27
</argument >
28
28
</arguments >
29
29
</type >
30
+ <type name =" Magento\Framework\App\Http" >
31
+ <plugin name =" framework-http-newrelic" type =" Magento\NewRelicReporting\Plugin\HttpPlugin" />
32
+ </type >
30
33
</config >
You can’t perform that action at this time.
0 commit comments