magento2: NewRelic Module cannot be removed

Preconditions (*)

  1. M2.4.4
  2. PHP8.1

Steps to reproduce (*)

  1. Remove NewRelic Entirely from composer
  2. Recompile the code

Expected result (*)

  1. All goes smooth, no issues

Actual result (*)

Area configuration aggregation... 5/9 [===============>------------]  55% 39 secs 370.0 MiB
In ClassReader.php line 57:
                                                                                                                                      
  Impossible to process constructor argument Parameter #0 [ <required> Magento\NewRelicReporting\Model\Config $config ] of Magento\   
  GraphQl\Model\Query\Logger\NewRelic class                                                                                           
                                                                                                                                      

In GetParameterClassTrait.php line 34:

  Class "Magento\NewRelicReporting\Model\Config" does not exist

Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 2
  • Comments: 26 (7 by maintainers)

Most upvoted comments

I suggest that the Magento core team uses https://github.com/yireo/Yireo_ExtensionChecker/ to make sure all dependencies are found 🙈

Confirmed with Magento 2.4.7-beta3, we can remove the magento/module-new-relic-reporting module again via composer and have a working setup:di:compile

FYI, you should probably also remove these 2 new modules that come with Magento 2.4.7 if you’re not interested in New Relic:

  • magento/module-application-performance-monitor-new-relic
  • magento/module-graph-ql-new-relic

We use GraphQL but not NewRelic, why the deep coupling between the two modules i have no clue, but here’s my cent

main issue might be: vendor/magento/module-graph-ql/etc/module.xml:12

Missing module sequence <module name="Magento_NewRelicReporting"/>

If you want to patch it while waiting for the core team to figure out how to resolve it:

You can use this patch: It removes the di.xml reference to the logger module and empties the vendor/magento/module-graph-ql/Model/Query/Logger/NewRelic.php file

--- etc/di.xml
+++ etc/di.xml
@@ -104,11 +104,4 @@
             <argument name="queryComplexity" xsi:type="number">300</argument>
         </arguments>
     </type>
-    <type name="Magento\GraphQl\Model\Query\Logger\LoggerPool">
-        <arguments>
-            <argument name="loggers" xsi:type="array">
-                <item name="newRelic" xsi:type="object">Magento\GraphQl\Model\Query\Logger\NewRelic</item>
-            </argument>
-        </arguments>
-    </type>
 </config>
--- Model/Query/Logger/NewRelic.php
+++ Model/Query/Logger/NewRelic.php
@@ -1,56 +0,0 @@
-<?php
-/**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
-
-namespace Magento\GraphQl\Model\Query\Logger;
-
-use Magento\NewRelicReporting\Model\Config;
-use Magento\NewRelicReporting\Model\NewRelicWrapper;
-
-/**
- * Logs GraphQl query data for New Relic
- */
-class NewRelic implements LoggerInterface
-{
-    /**
-     * @var Config
-     */
-    private $config;
-
-    /**
-     * @var NewRelicWrapper
-     */
-    private $newRelicWrapper;
-
-    /**
-     * @param Config $config
-     * @param NewRelicWrapper $newRelicWrapper
-     */
-    public function __construct(
-        Config $config,
-        NewRelicWrapper $newRelicWrapper
-    ) {
-        $this->config = $config;
-        $this->newRelicWrapper = $newRelicWrapper;
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function execute(array $queryDetails)
-    {
-        if (!$this->config->isNewRelicEnabled()) {
-            return;
-        }
-
-        foreach ($queryDetails as $key => $value) {
-            $this->newRelicWrapper->addCustomParameter($key, $value);
-        }
-
-        $transactionName = $queryDetails[LoggerInterface::OPERATION_NAMES] ?: '';
-
-        $this->newRelicWrapper->setTransactionName('GraphQL-' . $transactionName);
-    }
-}

I’ve also added the replace on the new relic module to remove it completely from composer

"replace": {
...
        "magento/module-new-relic-reporting": "*"
...
}

@engcom-Dash: add the following lines to your composer.json file:

    "replace": {
        "magento/module-new-relic-reporting": "*"
    }

Then execute composer update magento/module-new-relic-reporting (which should remove that package) and then execute bin/magento setup:upgrade (so it gets removed from the app/etc/config.php file). After that, re-try the steps from the opening post.

This is a common practice that Magento developers use to get rid of modules they don’t need, see this blog post if you’re interested.

I agree with the issue report, a dependency on the NewRelicReporting module should have never been made to the GraphQl module, that’s bad design! This was introduced in Magento 2.4.4 in scope of PWA-1311: New Relic is not being given useful transaction names for graphql requests It would have been better if a new module got created to connect graphql with new-relic-reporting, that would have been a much cleaner solution.

It is fixed and working as expected, I will close this issue.

@hostep agreed, that seems I applied the yireo replacement so find out this issue.

Is probably fixed internally by https://github.com/magento/magento2/commit/a495fed6e678da185a74de697c946e5637a781a1, I guess this is going to get included in Magento 2.4.7

Hi @hostep , The issue Confirmed and we are also Getting Same results. Here i Attached the Screenshot For your reference Screenshot from 2022-06-17 12-56-28

Thanks.