-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENGCOM-4634: #22047 Feature: Newrelic transaction name based on CLI n…
…ame #22059
- Loading branch information
Showing
3 changed files
with
74 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
app/code/Magento/NewRelicReporting/Plugin/CommandPlugin.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\NewRelicReporting\Plugin; | ||
|
||
use Magento\NewRelicReporting\Model\Config; | ||
use Magento\NewRelicReporting\Model\NewRelicWrapper; | ||
use Symfony\Component\Console\Command\Command; | ||
|
||
/** | ||
* Describe NewRelic commands plugin. | ||
*/ | ||
class CommandPlugin | ||
{ | ||
/** | ||
* @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; | ||
} | ||
|
||
/** | ||
* Set NewRelic Transaction name before running command. | ||
* | ||
* @param Command $command | ||
* @param array $args | ||
* @return array | ||
*/ | ||
public function beforeRun(Command $command, ...$args) | ||
{ | ||
$this->newRelicWrapper->setTransactionName( | ||
sprintf('CLI %s', $command->getName()) | ||
); | ||
|
||
return $args; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters