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
1 change: 0 additions & 1 deletion src/sentry/src/Aspect/CoroutineAspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class CoroutineAspect extends AbstractAspect
];

protected array $keys = [
// SentrySdk::class,
\Psr\Http\Message\ServerRequestInterface::class,
];

Expand Down
23 changes: 0 additions & 23 deletions src/sentry/src/Listener/EventHandleListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,15 +204,6 @@ protected function captureException(?Throwable $throwable): void
}
}

protected function flushEvents(): void
{
try {
Integration::flushEvents();
} catch (Throwable $e) {
$this->logger->error((string) $e);
}
}

/**
* @param BootApplication $event
*/
Expand Down Expand Up @@ -360,7 +351,6 @@ protected function handleRequestTerminated(object $event): void
}

$this->captureException($event->exception);
$this->flushEvents();
}

/**
Expand Down Expand Up @@ -428,7 +418,6 @@ protected function handleCommandFinished(object $event): void
}

$this->captureException($event->getThrowable());
$this->flushEvents();

Integration::configureScope(static function (Scope $scope): void {
$scope->removeTag('command');
Expand Down Expand Up @@ -468,8 +457,6 @@ protected function handleAsyncQueueJobProcessed(object $event): void
if (! $this->feature->isEnabled('async_queue')) {
return;
}

$this->flushEvents();
}

/**
Expand All @@ -482,7 +469,6 @@ protected function handleAsyncQueueJobRetryOrFailed(object $event): void
}

$this->captureException($event->getThrowable());
$this->flushEvents();
}

/**
Expand All @@ -503,8 +489,6 @@ protected function handleCrontabTaskFinished(object $event): void
if (! $this->feature->isEnabled('crontab')) {
return;
}

$this->flushEvents();
}

/**
Expand All @@ -517,7 +501,6 @@ protected function handleCrontabTaskFailed(object $event): void
}

$this->captureException($event->throwable);
$this->flushEvents();
}

/**
Expand All @@ -538,8 +521,6 @@ protected function handleAmqpMessageProcessed(object $event): void
if (! $this->feature->isEnabled('amqp')) {
return;
}

$this->flushEvents();
}

/**
Expand All @@ -552,7 +533,6 @@ protected function handleAmqpMessageFailed(object $event): void
}

$this->captureException($event->getThrowable());
$this->flushEvents();
}

/**
Expand All @@ -573,8 +553,6 @@ protected function handleKafkaMessageProcessed(object $event): void
if (! $this->feature->isEnabled('kafka')) {
return;
}

$this->flushEvents();
}

/**
Expand All @@ -587,7 +565,6 @@ protected function handleKafkaMessageFailed(object $event): void
}

$this->captureException($event->getThrowable());
$this->flushEvents();
}

/**
Expand Down
10 changes: 8 additions & 2 deletions src/sentry/src/Tracing/Aspect/CoroutineAspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace FriendsOfHyperf\Sentry\Tracing\Aspect;

use FriendsOfHyperf\Sentry\Feature;
use FriendsOfHyperf\Sentry\Integration;
use FriendsOfHyperf\Sentry\Util\CoroutineBacktraceHelper;
use Hyperf\Di\Aop\AbstractAspect;
use Hyperf\Di\Aop\ProceedingJoinPoint;
Expand All @@ -32,7 +33,6 @@ class CoroutineAspect extends AbstractAspect
];

protected array $keys = [
// SentrySdk::class,
\Psr\Http\Message\ServerRequestInterface::class,
];

Expand All @@ -57,7 +57,7 @@ public function process(ProceedingJoinPoint $proceedingJoinPoint)
return $proceedingJoinPoint->process();
}

// If there's no active transaction, skip tracing.
// Get the current transaction from the current scope.
$transaction = SentrySdk::getCurrentHub()->getTransaction();

// If there's no active transaction, skip tracing.
Expand Down Expand Up @@ -99,8 +99,14 @@ public function process(ProceedingJoinPoint $proceedingJoinPoint)
);

defer(function () use ($coTransaction) {
// Set the transaction on the current scope to ensure it's the active one.
SentrySdk::getCurrentHub()->setSpan($coTransaction);

// Finish the transaction when the coroutine ends.
$coTransaction->finish();

// Flush events
Integration::flushEvents();
});

try {
Expand Down
19 changes: 19 additions & 0 deletions src/sentry/src/Tracing/Listener/EventHandleListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Closure;
use FriendsOfHyperf\Sentry\Constants;
use FriendsOfHyperf\Sentry\Feature;
use FriendsOfHyperf\Sentry\Integration;
use FriendsOfHyperf\Sentry\Util\Carrier;
use FriendsOfHyperf\Sentry\Util\SqlParser;
use FriendsOfHyperf\Support\RedisCommand;
Expand Down Expand Up @@ -335,6 +336,9 @@ protected function handleRequestReceived(HttpEvent\RequestReceived|RpcEvent\Requ

// Finish transaction
$transaction->finish();

// Flush events
Integration::flushEvents();
});
}

Expand Down Expand Up @@ -396,6 +400,9 @@ protected function handleCommandStarting(CommandEvent\BeforeHandle $event): void

// Finish transaction
$transaction->finish();

// Flush events
Integration::flushEvents();
});
}

Expand Down Expand Up @@ -516,6 +523,9 @@ protected function handleCrontabTaskStarting(CrontabEvent\BeforeExecute $event):

// Finish transaction
$transaction->finish();

// Flush events
Integration::flushEvents();
});
}

Expand Down Expand Up @@ -586,6 +596,9 @@ protected function handleAmqpMessageProcessing(AmqpEvent\BeforeConsume $event):

// Finish transaction
$transaction->finish();

// Flush events
Integration::flushEvents();
});
}

Expand Down Expand Up @@ -656,6 +669,9 @@ protected function handleKafkaMessageProcessing(KafkaEvent\BeforeConsume $event)

// Finish transaction
$transaction->finish();

// Flush events
Integration::flushEvents();
});
}

Expand Down Expand Up @@ -709,6 +725,9 @@ protected function handleAsyncQueueJobProcessing(AsyncQueueEvent\BeforeHandle $e

// Finish transaction
$transaction->finish();

// Flush events
Integration::flushEvents();
});
}

Expand Down
Loading