File tree Expand file tree Collapse file tree 3 files changed +74
-3
lines changed
app/code/Magento/NewRelicReporting Expand file tree Collapse file tree 3 files changed +74
-3
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ class NewRelicWrapper
2121 */
2222 public function addCustomParameter ($ param , $ value )
2323 {
24- if (extension_loaded ( ' newrelic ' )) {
24+ if ($ this -> isExtensionInstalled ( )) {
2525 newrelic_add_custom_parameter ($ param , $ value );
2626 return true ;
2727 }
@@ -36,7 +36,7 @@ public function addCustomParameter($param, $value)
3636 */
3737 public function reportError ($ exception )
3838 {
39- if (extension_loaded ( ' newrelic ' )) {
39+ if ($ this -> isExtensionInstalled ( )) {
4040 newrelic_notice_error ($ exception ->getMessage (), $ exception );
4141 }
4242 }
@@ -49,11 +49,24 @@ public function reportError($exception)
4949 */
5050 public function setAppName (string $ appName )
5151 {
52- if (extension_loaded ( ' newrelic ' )) {
52+ if ($ this -> isExtensionInstalled ( )) {
5353 newrelic_set_appname ($ appName );
5454 }
5555 }
5656
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+
5770 /**
5871 * Checks whether newrelic-php5 agent is installed
5972 *
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 4040 </argument >
4141 </arguments >
4242 </type >
43+ <type name =" Symfony\Component\Console\Command\Command" >
44+ <plugin name =" newrelic-describe-commands" type =" Magento\NewRelicReporting\Plugin\CommandPlugin" />
45+ </type >
4346</config >
You can’t perform that action at this time.
0 commit comments