-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TE-10997: Group transactions by command argument (#9296)
TE-10997 Group transactions by command name and argument
- Loading branch information
Anton Sakharov
authored
Jun 2, 2022
1 parent
defb86d
commit ddcfbac
Showing
5 changed files
with
131 additions
and
2 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
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
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
53 changes: 53 additions & 0 deletions
53
...ringTransactionNamingStrategy/FirstArgumentMonitoringConsoleTransactionNamingStrategy.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,53 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © 2016-present Spryker Systems GmbH. All rights reserved. | ||
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. | ||
*/ | ||
|
||
namespace Spryker\Zed\Monitoring\Business\MonitoringTransactionNamingStrategy; | ||
|
||
use Generated\Shared\Transfer\MonitoringTransactionEventTransfer; | ||
|
||
class FirstArgumentMonitoringConsoleTransactionNamingStrategy implements MonitoringTransactionNamingStrategyInterface | ||
{ | ||
/** | ||
* @var array<string> | ||
*/ | ||
protected array $commandNames = []; | ||
|
||
/** | ||
* @param array<string> $commandNames | ||
*/ | ||
public function __construct(array $commandNames) | ||
{ | ||
$this->commandNames = $commandNames; | ||
} | ||
|
||
/** | ||
* @param \Generated\Shared\Transfer\MonitoringTransactionEventTransfer $monitoringTransactionEventTransfer | ||
* | ||
* @return bool | ||
*/ | ||
public function isApplicable( | ||
MonitoringTransactionEventTransfer $monitoringTransactionEventTransfer | ||
): bool { | ||
return in_array($monitoringTransactionEventTransfer->getCommandName(), $this->commandNames, true); | ||
} | ||
|
||
/** | ||
* @param \Generated\Shared\Transfer\MonitoringTransactionEventTransfer $monitoringTransactionEventTransfer | ||
* | ||
* @return string|null | ||
*/ | ||
public function getMonitoringTransactionName( | ||
MonitoringTransactionEventTransfer $monitoringTransactionEventTransfer | ||
): ?string { | ||
$arguments = array_values($monitoringTransactionEventTransfer->getArguments()); | ||
$commandName = $monitoringTransactionEventTransfer->getCommandName(); | ||
$transactionNamePrefix = $monitoringTransactionEventTransfer->getTransactionNamePrefix(); | ||
$argumentValue = $arguments[1] ?? ''; | ||
|
||
return implode(' ', [$transactionNamePrefix, $commandName, $argumentValue]); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...ness/MonitoringTransactionNamingStrategy/MonitoringTransactionNamingStrategyInterface.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,27 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © 2016-present Spryker Systems GmbH. All rights reserved. | ||
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. | ||
*/ | ||
|
||
namespace Spryker\Zed\Monitoring\Business\MonitoringTransactionNamingStrategy; | ||
|
||
use Generated\Shared\Transfer\MonitoringTransactionEventTransfer; | ||
|
||
interface MonitoringTransactionNamingStrategyInterface | ||
{ | ||
/** | ||
* @param \Generated\Shared\Transfer\MonitoringTransactionEventTransfer $monitoringTransactionEventTransfer | ||
* | ||
* @return bool | ||
*/ | ||
public function isApplicable(MonitoringTransactionEventTransfer $monitoringTransactionEventTransfer): bool; | ||
|
||
/** | ||
* @param \Generated\Shared\Transfer\MonitoringTransactionEventTransfer $monitoringTransactionEventTransfer | ||
* | ||
* @return string|null | ||
*/ | ||
public function getMonitoringTransactionName(MonitoringTransactionEventTransfer $monitoringTransactionEventTransfer): ?string; | ||
} |