File tree 3 files changed +74
-3
lines changed
app/code/Magento/NewRelicReporting
3 files changed +74
-3
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ class NewRelicWrapper
21
21
*/
22
22
public function addCustomParameter ($ param , $ value )
23
23
{
24
- if (extension_loaded ( ' newrelic ' )) {
24
+ if ($ this -> isExtensionInstalled ( )) {
25
25
newrelic_add_custom_parameter ($ param , $ value );
26
26
return true ;
27
27
}
@@ -36,7 +36,7 @@ public function addCustomParameter($param, $value)
36
36
*/
37
37
public function reportError ($ exception )
38
38
{
39
- if (extension_loaded ( ' newrelic ' )) {
39
+ if ($ this -> isExtensionInstalled ( )) {
40
40
newrelic_notice_error ($ exception ->getMessage (), $ exception );
41
41
}
42
42
}
@@ -49,11 +49,24 @@ 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
}
56
56
57
+ /**
58
+ * Wrapper for 'newrelic_name_transaction'
59
+ *
60
+ * @param string $transactionName
61
+ * @return void
62
+ */
63
+ public function setTransactionName (string $ transactionName ): void
64
+ {
65
+ if ($ this ->isExtensionInstalled ()) {
66
+ newrelic_name_transaction ($ transactionName );
67
+ }
68
+ }
69
+
57
70
/**
58
71
* Checks whether newrelic-php5 agent is installed
59
72
*
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
+
7
+ namespace Magento \NewRelicReporting \Plugin ;
8
+
9
+ use Magento \NewRelicReporting \Model \Config ;
10
+ use Magento \NewRelicReporting \Model \NewRelicWrapper ;
11
+ use Symfony \Component \Console \Command \Command ;
12
+
13
+ /**
14
+ * Describe NewRelic commands plugin.
15
+ */
16
+ class CommandPlugin
17
+ {
18
+ /**
19
+ * @var Config
20
+ */
21
+ private $ config ;
22
+
23
+ /**
24
+ * @var NewRelicWrapper
25
+ */
26
+ private $ newRelicWrapper ;
27
+
28
+ /**
29
+ * @param Config $config
30
+ * @param NewRelicWrapper $newRelicWrapper
31
+ */
32
+ public function __construct (
33
+ Config $ config ,
34
+ NewRelicWrapper $ newRelicWrapper
35
+ ) {
36
+ $ this ->config = $ config ;
37
+ $ this ->newRelicWrapper = $ newRelicWrapper ;
38
+ }
39
+
40
+ /**
41
+ * Set NewRelic Transaction name before running command.
42
+ *
43
+ * @param Command $command
44
+ * @param array $args
45
+ * @return array
46
+ */
47
+ public function beforeRun (Command $ command , ...$ args )
48
+ {
49
+ $ this ->newRelicWrapper ->setTransactionName (
50
+ sprintf ('CLI %s ' , $ command ->getName ())
51
+ );
52
+
53
+ return $ args ;
54
+ }
55
+ }
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