Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions app/code/Magento/NewRelicReporting/Model/NewRelicWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@ public function addCustomParameter($param, $value)
return false;
}

/**
* Wrapper for 'newrelic_notice_error' function
*
* @param Exception $exception
* @return void
*/
public function reportError($exception)
{
if (extension_loaded('newrelic')) {
newrelic_notice_error($exception->getMessage(), $exception);
}
}

/**
* Checks whether newrelic-php5 agent is installed
*
Expand Down
53 changes: 53 additions & 0 deletions app/code/Magento/NewRelicReporting/Plugin/HttpPlugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\NewRelicReporting\Plugin;

use Magento\Framework\App\Bootstrap;
use Magento\Framework\App\Http;
use Magento\NewRelicReporting\Model\Config;
use Magento\NewRelicReporting\Model\NewRelicWrapper;

class HttpPlugin
{
/**
* @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;
}

/**
* Report exception to New Relic
*
* @param Http $subject
* @param Bootstrap $bootstrap
* @param \Exception $exception
* @return void
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function beforeCatchException(Http $subject, Bootstrap $bootstrap, \Exception $exception)
{
if ($this->config->isNewRelicEnabled()) {
$this->newRelicWrapper->reportError($exception);
}
}
}
3 changes: 3 additions & 0 deletions app/code/Magento/NewRelicReporting/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,7 @@
</argument>
</arguments>
</type>
<type name="Magento\Framework\App\Http">
<plugin name="framework-http-newrelic" type="Magento\NewRelicReporting\Plugin\HttpPlugin"/>
</type>
</config>