File tree Expand file tree Collapse file tree 3 files changed +61
-1
lines changed
app/code/Magento/NewRelicReporting Expand file tree Collapse file tree 3 files changed +61
-1
lines changed Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ public function reportError($exception)
49
49
*/
50
50
public function setAppName (string $ appName )
51
51
{
52
- if (extension_loaded ( ' newrelic ' )) {
52
+ if ($ this -> isExtensionInstalled ( )) {
53
53
newrelic_set_appname ($ appName );
54
54
}
55
55
}
@@ -66,4 +66,17 @@ public function isExtensionInstalled()
66
66
}
67
67
return false ;
68
68
}
69
+
70
+ /**
71
+ * Wrapper for 'newrelic_name_transaction'
72
+ *
73
+ * @param string $transactionName
74
+ * @return void
75
+ */
76
+ public function setTransactionName (string $ transactionName ): void
77
+ {
78
+ if ($ this ->isExtensionInstalled ()) {
79
+ newrelic_name_transaction ($ transactionName );
80
+ }
81
+ }
69
82
}
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 \Exception \LocalizedException ;
9
+ use Magento \NewRelicReporting \Model \Config ;
10
+ use Magento \NewRelicReporting \Model \NewRelicWrapper ;
11
+
12
+ class CommandPlugin
13
+ {
14
+ /**
15
+ * @var Config
16
+ */
17
+ private $ config ;
18
+
19
+ /**
20
+ * @var NewRelicWrapper
21
+ */
22
+ private $ 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 beforeRun (\Symfony \Component \Console \Command \Command $ command , ...$ args )
37
+ {
38
+ $ this ->newRelicWrapper ->setTransactionName (
39
+ sprintf ('CLI %s ' , $ command ->getName ())
40
+ );
41
+
42
+ return $ args ;
43
+ }
44
+ }
Original file line number Diff line number Diff line change 40
40
</argument >
41
41
</arguments >
42
42
</type >
43
+ <type name =" Symfony\Component\Console\Command\Command" >
44
+ <plugin name =" newrelic-describe-commands" type =" Magento\NewRelicReporting\Plugin\CommandPlugin" />
45
+ </type >
43
46
</config >
You can’t perform that action at this time.
0 commit comments