Skip to content

Commit

Permalink
Support ignore commands (#389)
Browse files Browse the repository at this point in the history
Co-authored-by: Deeka Wong <[email protected]>
  • Loading branch information
huangdijia and huangdijia authored Oct 30, 2023
1 parent 128da78 commit 834e9e5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions publish/sentry.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@
'GET /health',
],

'ignore_commands' => [
'tinker',
],

// Performance monitoring specific configuration
'tracing' => [
'enable' => [
Expand Down
1 change: 1 addition & 0 deletions src/Factory/ClientBuilderFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class ClientBuilderFactory
{
public const SPECIFIC_OPTIONS = [
'breadcrumbs',
'ignore_commands',
'integrations',
'enable',
'tracing',
Expand Down
9 changes: 9 additions & 0 deletions src/Tracing/Listener/TracingCommandListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use FriendsOfHyperf\Sentry\Tracing\TraceContext;
use Hyperf\Command\Event\AfterExecute;
use Hyperf\Command\Event\BeforeHandle;
use Hyperf\Contract\ConfigInterface;
use Hyperf\Event\Contract\ListenerInterface;
use Sentry\SentrySdk;
use Sentry\State\HubInterface;
Expand All @@ -30,10 +31,14 @@
*/
class TracingCommandListener implements ListenerInterface
{
protected array $ignoreCommands = [];

public function __construct(
ConfigInterface $config,
protected Switcher $switcher,
protected TagManager $tagManager
) {
$this->ignoreCommands = $config->get('sentry.ignore_commands', []);
}

public function listen(): array
Expand All @@ -49,6 +54,10 @@ public function listen(): array
*/
public function process(object $event): void
{
if (in_array($event->getCommand()->getName(), $this->ignoreCommands)) {
return;
}

$sentry = SentrySdk::getCurrentHub();

match ($event::class) {
Expand Down

0 comments on commit 834e9e5

Please sign in to comment.