From b47a4405cc70b6ae4d916d3c30579296a0dc5439 Mon Sep 17 00:00:00 2001 From: Martin Linzmayer Date: Thu, 16 Jul 2026 15:41:22 +0200 Subject: [PATCH 1/2] ref(scopes): feedback from stacked PRs --- .../AbstractErrorListenerIntegration.php | 4 +- src/Monolog/ExceptionToSentryIssueHandler.php | 4 +- src/Monolog/LogToSentryIssueHandler.php | 4 +- .../{EventCapturer.php => EventRecorder.php} | 40 +++++++------- src/Tracing/Transaction.php | 16 ++++-- src/functions.php | 53 ++++++++++--------- tests/FunctionsTest.php | 21 ++++++++ ...CapturerTest.php => EventRecorderTest.php} | 21 ++++---- tests/Tracing/TransactionTest.php | 8 ++- 9 files changed, 104 insertions(+), 67 deletions(-) rename src/State/{EventCapturer.php => EventRecorder.php} (61%) rename tests/State/{EventCapturerTest.php => EventRecorderTest.php} (90%) diff --git a/src/Integration/AbstractErrorListenerIntegration.php b/src/Integration/AbstractErrorListenerIntegration.php index 36482a987..9b1cc8a0d 100644 --- a/src/Integration/AbstractErrorListenerIntegration.php +++ b/src/Integration/AbstractErrorListenerIntegration.php @@ -7,7 +7,7 @@ use Sentry\Event; use Sentry\EventHint; use Sentry\ExceptionMechanism; -use Sentry\State\EventCapturer; +use Sentry\State\EventRecorder; use Sentry\State\IsolationScope; use function Sentry\withIsolationScope; @@ -24,7 +24,7 @@ protected function captureException(\Throwable $exception): void return $this->addExceptionMechanismToEvent($event); }); - EventCapturer::captureException($exception); + EventRecorder::captureException($exception, null, $scope); }); } diff --git a/src/Monolog/ExceptionToSentryIssueHandler.php b/src/Monolog/ExceptionToSentryIssueHandler.php index 7998c9c83..5173631d5 100644 --- a/src/Monolog/ExceptionToSentryIssueHandler.php +++ b/src/Monolog/ExceptionToSentryIssueHandler.php @@ -9,7 +9,7 @@ use Monolog\Logger; use Monolog\LogRecord; use Psr\Log\LogLevel; -use Sentry\State\EventCapturer; +use Sentry\State\EventRecorder; use Sentry\State\IsolationScope; use function Sentry\withIsolationScope; @@ -56,7 +56,7 @@ public function handle($record): bool $scope->setExtra('monolog.extra', $monologExtraData); } - EventCapturer::captureException($exception); + EventRecorder::captureException($exception, null, $scope); }); return $this->bubble === false; diff --git a/src/Monolog/LogToSentryIssueHandler.php b/src/Monolog/LogToSentryIssueHandler.php index f38f03020..2866d32af 100644 --- a/src/Monolog/LogToSentryIssueHandler.php +++ b/src/Monolog/LogToSentryIssueHandler.php @@ -11,7 +11,7 @@ use Psr\Log\LogLevel; use Sentry\Event; use Sentry\EventHint; -use Sentry\State\EventCapturer; +use Sentry\State\EventRecorder; use Sentry\State\IsolationScope; use function Sentry\withIsolationScope; @@ -84,7 +84,7 @@ protected function doWrite($record): void } } - EventCapturer::captureEvent($event, $hint); + EventRecorder::captureEvent($event, $hint, $scope); }); } diff --git a/src/State/EventCapturer.php b/src/State/EventRecorder.php similarity index 61% rename from src/State/EventCapturer.php rename to src/State/EventRecorder.php index a21b44e75..dbc6c4f41 100644 --- a/src/State/EventCapturer.php +++ b/src/State/EventRecorder.php @@ -18,36 +18,44 @@ /** * @internal */ -final class EventCapturer +final class EventRecorder { private function __construct() { } - public static function captureMessage(string $message, ?Severity $level = null, ?EventHint $hint = null): ?EventId + public static function captureMessage(string $message, ?Severity $level = null, ?EventHint $hint = null, ?IsolationScope $isolationScope = null): ?EventId { - return self::capture(static function (ClientInterface $client, IsolationScope $captureScope) use ($message, $level, $hint): ?EventId { + $isolationScope = $isolationScope ?? SentrySdk::getIsolationScope(); + + return self::captureWithScope(SentrySdk::getClient($isolationScope), $isolationScope, static function (ClientInterface $client, IsolationScope $captureScope) use ($message, $level, $hint): ?EventId { return $client->captureMessage($message, $level, $captureScope, $hint); }); } - public static function captureException(\Throwable $exception, ?EventHint $hint = null): ?EventId + public static function captureException(\Throwable $exception, ?EventHint $hint = null, ?IsolationScope $isolationScope = null): ?EventId { - return self::capture(static function (ClientInterface $client, IsolationScope $captureScope) use ($exception, $hint): ?EventId { + $isolationScope = $isolationScope ?? SentrySdk::getIsolationScope(); + + return self::captureWithScope(SentrySdk::getClient($isolationScope), $isolationScope, static function (ClientInterface $client, IsolationScope $captureScope) use ($exception, $hint): ?EventId { return $client->captureException($exception, $captureScope, $hint); }); } - public static function captureEvent(Event $event, ?EventHint $hint = null): ?EventId + public static function captureEvent(Event $event, ?EventHint $hint = null, ?IsolationScope $isolationScope = null): ?EventId { - return self::capture(static function (ClientInterface $client, IsolationScope $captureScope) use ($event, $hint): ?EventId { + $isolationScope = $isolationScope ?? SentrySdk::getIsolationScope(); + + return self::captureWithScope(SentrySdk::getClient($isolationScope), $isolationScope, static function (ClientInterface $client, IsolationScope $captureScope) use ($event, $hint): ?EventId { return $client->captureEvent($event, $hint, $captureScope); }); } - public static function captureLastError(?EventHint $hint = null): ?EventId + public static function captureLastError(?EventHint $hint = null, ?IsolationScope $isolationScope = null): ?EventId { - return self::capture(static function (ClientInterface $client, IsolationScope $captureScope) use ($hint): ?EventId { + $isolationScope = $isolationScope ?? SentrySdk::getIsolationScope(); + + return self::captureWithScope(SentrySdk::getClient($isolationScope), $isolationScope, static function (ClientInterface $client, IsolationScope $captureScope) use ($hint): ?EventId { return $client->captureLastError($captureScope, $hint); }); } @@ -55,9 +63,9 @@ public static function captureLastError(?EventHint $hint = null): ?EventId /** * @param int|float|null $duration */ - public static function captureCheckIn(string $slug, CheckInStatus $status, $duration = null, ?MonitorConfig $monitorConfig = null, ?string $checkInId = null): ?string + public static function captureCheckIn(string $slug, CheckInStatus $status, $duration = null, ?MonitorConfig $monitorConfig = null, ?string $checkInId = null, ?IsolationScope $isolationScope = null): ?string { - $isolationScope = SentrySdk::getIsolationScope(); + $isolationScope = $isolationScope ?? SentrySdk::getIsolationScope(); $client = SentrySdk::getClient($isolationScope); if ($client instanceof NoOpClient) { @@ -84,16 +92,6 @@ public static function captureCheckIn(string $slug, CheckInStatus $status, $dura return $checkIn->getId(); } - /** - * @param callable(ClientInterface, IsolationScope): ?EventId $capture - */ - private static function capture(callable $capture): ?EventId - { - $isolationScope = SentrySdk::getIsolationScope(); - - return self::captureWithScope(SentrySdk::getClient($isolationScope), $isolationScope, $capture); - } - /** * @param callable(ClientInterface, IsolationScope): ?EventId $capture */ diff --git a/src/Tracing/Transaction.php b/src/Tracing/Transaction.php index 89086bc96..2b3cba6b1 100644 --- a/src/Tracing/Transaction.php +++ b/src/Tracing/Transaction.php @@ -9,6 +9,8 @@ use Sentry\Options; use Sentry\Profiling\Profiler; use Sentry\SentrySdk; +use Sentry\State\EventRecorder; +use Sentry\State\IsolationScope; /** * This class stores all the information about a Transaction. @@ -20,6 +22,11 @@ final class Transaction extends Span */ private $name; + /** + * @var IsolationScope + */ + private $scope; + /** * @var Transaction The transaction */ @@ -42,11 +49,12 @@ final class Transaction extends Span * * @internal */ - public function __construct(TransactionContext $context) + public function __construct(TransactionContext $context, ?IsolationScope $scope = null) { parent::__construct($context); $this->name = $context->getName(); + $this->scope = $scope ?? SentrySdk::getIsolationScope(); $this->metadata = $context->getMetadata(); $this->transaction = $this; } @@ -90,7 +98,7 @@ public function getDynamicSamplingContext(): DynamicSamplingContext return $this->metadata->getDynamicSamplingContext(); } - $samplingContext = DynamicSamplingContext::fromTransaction($this->transaction, SentrySdk::getClient()); + $samplingContext = DynamicSamplingContext::fromTransaction($this->transaction, SentrySdk::getClient($this->scope)); $this->getMetadata()->setDynamicSamplingContext($samplingContext); return $samplingContext; @@ -115,7 +123,7 @@ public function initSpanRecorder(int $maxSpans = 1000): self public function initProfiler(?Options $options = null): Profiler { if ($this->profiler === null) { - $this->profiler = new Profiler($options ?? SentrySdk::getClient()->getOptions()); + $this->profiler = new Profiler($options ?? SentrySdk::getClient($this->scope)->getOptions()); } return $this->profiler; @@ -180,6 +188,6 @@ public function finish(?float $endTimestamp = null): ?EventId } } - return \Sentry\captureEvent($event); + return EventRecorder::captureEvent($event, null, $this->scope); } } diff --git a/src/functions.php b/src/functions.php index bb234f982..426d8bb2c 100644 --- a/src/functions.php +++ b/src/functions.php @@ -11,7 +11,7 @@ use Sentry\Logs\Logs; use Sentry\Metrics\TraceMetrics; use Sentry\State\BreadcrumbRecorder; -use Sentry\State\EventCapturer; +use Sentry\State\EventRecorder; use Sentry\State\GlobalScope; use Sentry\State\IsolationScope; use Sentry\State\Scope; @@ -99,59 +99,64 @@ function getClient(): ClientInterface /** * Captures a message event and sends it to Sentry. * - * @param string $message The message - * @param Severity|null $level The severity level of the message - * @param EventHint|null $hint Object that can contain additional information about the event + * @param string $message The message + * @param Severity|null $level The severity level of the message + * @param EventHint|null $hint Object that can contain additional information about the event + * @param IsolationScope|null $scope The scope to capture the event with */ -function captureMessage(string $message, ?Severity $level = null, ?EventHint $hint = null): ?EventId +function captureMessage(string $message, ?Severity $level = null, ?EventHint $hint = null, ?IsolationScope $scope = null): ?EventId { - return EventCapturer::captureMessage($message, $level, $hint); + return EventRecorder::captureMessage($message, $level, $hint, $scope); } /** * Captures an exception event and sends it to Sentry. * - * @param \Throwable $exception The exception - * @param EventHint|null $hint Object that can contain additional information about the event + * @param \Throwable $exception The exception + * @param EventHint|null $hint Object that can contain additional information about the event + * @param IsolationScope|null $scope The scope to capture the event with */ -function captureException(\Throwable $exception, ?EventHint $hint = null): ?EventId +function captureException(\Throwable $exception, ?EventHint $hint = null, ?IsolationScope $scope = null): ?EventId { - return EventCapturer::captureException($exception, $hint); + return EventRecorder::captureException($exception, $hint, $scope); } /** * Captures a new event using the provided data. * - * @param Event $event The event being captured - * @param EventHint|null $hint May contain additional information about the event + * @param Event $event The event being captured + * @param EventHint|null $hint May contain additional information about the event + * @param IsolationScope|null $scope The scope to capture the event with */ -function captureEvent(Event $event, ?EventHint $hint = null): ?EventId +function captureEvent(Event $event, ?EventHint $hint = null, ?IsolationScope $scope = null): ?EventId { - return EventCapturer::captureEvent($event, $hint); + return EventRecorder::captureEvent($event, $hint, $scope); } /** * Logs the most recent error (obtained with {@see error_get_last()}). * - * @param EventHint|null $hint Object that can contain additional information about the event + * @param EventHint|null $hint Object that can contain additional information about the event + * @param IsolationScope|null $scope The scope to capture the event with */ -function captureLastError(?EventHint $hint = null): ?EventId +function captureLastError(?EventHint $hint = null, ?IsolationScope $scope = null): ?EventId { - return EventCapturer::captureLastError($hint); + return EventRecorder::captureLastError($hint, $scope); } /** * Captures a check-in and sends it to Sentry. * - * @param string $slug Identifier of the Monitor - * @param CheckInStatus $status The status of the check-in - * @param int|float|null $duration The duration of the check-in - * @param MonitorConfig|null $monitorConfig Configuration of the Monitor - * @param string|null $checkInId A check-in ID from the previous check-in + * @param string $slug Identifier of the Monitor + * @param CheckInStatus $status The status of the check-in + * @param int|float|null $duration The duration of the check-in + * @param MonitorConfig|null $monitorConfig Configuration of the Monitor + * @param string|null $checkInId A check-in ID from the previous check-in + * @param IsolationScope|null $scope The scope to capture the check-in with */ -function captureCheckIn(string $slug, CheckInStatus $status, $duration = null, ?MonitorConfig $monitorConfig = null, ?string $checkInId = null): ?string +function captureCheckIn(string $slug, CheckInStatus $status, $duration = null, ?MonitorConfig $monitorConfig = null, ?string $checkInId = null, ?IsolationScope $scope = null): ?string { - return EventCapturer::captureCheckIn($slug, $status, $duration, $monitorConfig, $checkInId); + return EventRecorder::captureCheckIn($slug, $status, $duration, $monitorConfig, $checkInId, $scope); } /** diff --git a/tests/FunctionsTest.php b/tests/FunctionsTest.php index c0e597a4f..7471b9780 100644 --- a/tests/FunctionsTest.php +++ b/tests/FunctionsTest.php @@ -192,6 +192,27 @@ public function testCaptureEvent(): void $this->assertSame($event->getId(), $scope->getLastEventId()); } + public function testCaptureEventWithExplicitScope(): void + { + $event = Event::createEvent(); + $eventId = $event->getId(); + $client = $this->createMock(ClientInterface::class); + $currentScope = $this->setClientAndIsolationScope($this->createMock(ClientInterface::class)); + $scope = new IsolationScope(); + $scope->setTag('scope', 'isolation'); + $scope->setTag('isolation', 'yes'); + $scope->setClient($client); + + $client->expects($this->once()) + ->method('captureEvent') + ->with($event, null, $this->captureScopeConstraint($scope)) + ->willReturn($eventId); + + $this->assertSame($eventId, captureEvent($event, null, $scope)); + $this->assertSame($eventId, $scope->getLastEventId()); + $this->assertNull($currentScope->getLastEventId()); + } + /** * @dataProvider captureLastErrorDataProvider */ diff --git a/tests/State/EventCapturerTest.php b/tests/State/EventRecorderTest.php similarity index 90% rename from tests/State/EventCapturerTest.php rename to tests/State/EventRecorderTest.php index 3d8c985f4..8eb644697 100644 --- a/tests/State/EventCapturerTest.php +++ b/tests/State/EventRecorderTest.php @@ -16,11 +16,11 @@ use Sentry\Options; use Sentry\SentrySdk; use Sentry\Severity; -use Sentry\State\EventCapturer; +use Sentry\State\EventRecorder; use Sentry\State\IsolationScope; use Sentry\Util\SentryUid; -final class EventCapturerTest extends TestCase +final class EventRecorderTest extends TestCase { public function testCaptureMessagePassesIsolationScopeAndStoresLastEventId(): void { @@ -36,7 +36,7 @@ public function testCaptureMessagePassesIsolationScopeAndStoresLastEventId(): vo }), $hint) ->willReturn($eventId); - $this->assertSame($eventId, EventCapturer::captureMessage('foo', Severity::debug(), $hint)); + $this->assertSame($eventId, EventRecorder::captureMessage('foo', Severity::debug(), $hint, $isolationScope)); $this->assertSame($eventId, $isolationScope->getLastEventId()); } @@ -55,7 +55,7 @@ public function testCaptureExceptionPassesIsolationScopeAndStoresLastEventId(): }), $hint) ->willReturn($eventId); - $this->assertSame($eventId, EventCapturer::captureException($exception, $hint)); + $this->assertSame($eventId, EventRecorder::captureException($exception, $hint, $isolationScope)); $this->assertSame($eventId, $isolationScope->getLastEventId()); } @@ -73,7 +73,7 @@ public function testCaptureEventPassesIsolationScopeAndStoresLastEventId(): void })) ->willReturn($event->getId()); - $this->assertSame($event->getId(), EventCapturer::captureEvent($event, $hint)); + $this->assertSame($event->getId(), EventRecorder::captureEvent($event, $hint, $isolationScope)); $this->assertSame($event->getId(), $isolationScope->getLastEventId()); } @@ -91,7 +91,7 @@ public function testCaptureLastErrorPassesIsolationScopeAndStoresLastEventId(): }), $hint) ->willReturn($eventId); - $this->assertSame($eventId, EventCapturer::captureLastError($hint)); + $this->assertSame($eventId, EventRecorder::captureLastError($hint, $isolationScope)); $this->assertSame($eventId, $isolationScope->getLastEventId()); } @@ -109,7 +109,7 @@ public function testCaptureEventClearsLastEventIdWhenClientReturnsNull(): void })) ->willReturn(null); - $this->assertNull(EventCapturer::captureEvent($event)); + $this->assertNull(EventRecorder::captureEvent($event)); $this->assertNull($isolationScope->getLastEventId()); } @@ -150,12 +150,13 @@ public function testCaptureCheckInCreatesEventAndStoresLastEventId(): void })) ->willReturn($eventId); - $this->assertSame($checkInId, EventCapturer::captureCheckIn( + $this->assertSame($checkInId, EventRecorder::captureCheckIn( 'test-crontab', CheckInStatus::ok(), 10, $monitorConfig, - $checkInId + $checkInId, + $isolationScope )); $this->assertSame($eventId, $isolationScope->getLastEventId()); } @@ -166,7 +167,7 @@ public function testCaptureCheckInReturnsNullForNoOpClient(): void $eventId = EventId::generate(); SentrySdk::getIsolationScope()->setLastEventId($eventId); - $this->assertNull(EventCapturer::captureCheckIn('test-crontab', CheckInStatus::ok())); + $this->assertNull(EventRecorder::captureCheckIn('test-crontab', CheckInStatus::ok())); $this->assertSame($eventId, SentrySdk::getIsolationScope()->getLastEventId()); } diff --git a/tests/Tracing/TransactionTest.php b/tests/Tracing/TransactionTest.php index cfb2eb959..aff82026f 100644 --- a/tests/Tracing/TransactionTest.php +++ b/tests/Tracing/TransactionTest.php @@ -41,7 +41,9 @@ public function testFinish(): void SentrySdk::init($client); - $transaction = new Transaction($transactionContext); + $scope = SentrySdk::getIsolationScope(); + $transaction = new Transaction($transactionContext, $scope); + SentrySdk::getCurrentRuntimeContext()->setIsolationScope(new IsolationScope()); $transaction->initSpanRecorder(); $span1 = $transaction->startChild(new SpanContext()); @@ -59,7 +61,7 @@ public function testFinish(): void $this->assertSame([$span1, $span2], $eventArg->getSpans()); return true; - }), null, $this->isInstanceOf(IsolationScope::class)) + }), null, $scope) ->willReturnCallback(static function (Event $eventArg) use (&$expectedEventId): EventId { $expectedEventId = $eventArg->getId(); @@ -72,6 +74,8 @@ public function testFinish(): void $eventId = $transaction->finish(); $this->assertSame($expectedEventId, $eventId); + $this->assertSame($expectedEventId, $scope->getLastEventId()); + $this->assertNull(SentrySdk::getIsolationScope()->getLastEventId()); } public function testFinishDoesNothingIfSampledFlagIsNotTrue(): void From eaded711c95abd5f4b1aaabce39b1f389d6b4983 Mon Sep 17 00:00:00 2001 From: Martin Linzmayer Date: Thu, 16 Jul 2026 15:47:04 +0200 Subject: [PATCH 2/2] fix --- src/functions.php | 51 +++++++++++++++++++---------------------- tests/FunctionsTest.php | 21 ----------------- 2 files changed, 23 insertions(+), 49 deletions(-) diff --git a/src/functions.php b/src/functions.php index 426d8bb2c..84aadd28e 100644 --- a/src/functions.php +++ b/src/functions.php @@ -99,64 +99,59 @@ function getClient(): ClientInterface /** * Captures a message event and sends it to Sentry. * - * @param string $message The message - * @param Severity|null $level The severity level of the message - * @param EventHint|null $hint Object that can contain additional information about the event - * @param IsolationScope|null $scope The scope to capture the event with + * @param string $message The message + * @param Severity|null $level The severity level of the message + * @param EventHint|null $hint Object that can contain additional information about the event */ -function captureMessage(string $message, ?Severity $level = null, ?EventHint $hint = null, ?IsolationScope $scope = null): ?EventId +function captureMessage(string $message, ?Severity $level = null, ?EventHint $hint = null): ?EventId { - return EventRecorder::captureMessage($message, $level, $hint, $scope); + return EventRecorder::captureMessage($message, $level, $hint); } /** * Captures an exception event and sends it to Sentry. * - * @param \Throwable $exception The exception - * @param EventHint|null $hint Object that can contain additional information about the event - * @param IsolationScope|null $scope The scope to capture the event with + * @param \Throwable $exception The exception + * @param EventHint|null $hint Object that can contain additional information about the event */ -function captureException(\Throwable $exception, ?EventHint $hint = null, ?IsolationScope $scope = null): ?EventId +function captureException(\Throwable $exception, ?EventHint $hint = null): ?EventId { - return EventRecorder::captureException($exception, $hint, $scope); + return EventRecorder::captureException($exception, $hint); } /** * Captures a new event using the provided data. * - * @param Event $event The event being captured - * @param EventHint|null $hint May contain additional information about the event - * @param IsolationScope|null $scope The scope to capture the event with + * @param Event $event The event being captured + * @param EventHint|null $hint May contain additional information about the event */ -function captureEvent(Event $event, ?EventHint $hint = null, ?IsolationScope $scope = null): ?EventId +function captureEvent(Event $event, ?EventHint $hint = null): ?EventId { - return EventRecorder::captureEvent($event, $hint, $scope); + return EventRecorder::captureEvent($event, $hint); } /** * Logs the most recent error (obtained with {@see error_get_last()}). * - * @param EventHint|null $hint Object that can contain additional information about the event - * @param IsolationScope|null $scope The scope to capture the event with + * @param EventHint|null $hint Object that can contain additional information about the event */ -function captureLastError(?EventHint $hint = null, ?IsolationScope $scope = null): ?EventId +function captureLastError(?EventHint $hint = null): ?EventId { - return EventRecorder::captureLastError($hint, $scope); + return EventRecorder::captureLastError($hint); } /** * Captures a check-in and sends it to Sentry. * - * @param string $slug Identifier of the Monitor - * @param CheckInStatus $status The status of the check-in - * @param int|float|null $duration The duration of the check-in - * @param MonitorConfig|null $monitorConfig Configuration of the Monitor - * @param string|null $checkInId A check-in ID from the previous check-in - * @param IsolationScope|null $scope The scope to capture the check-in with + * @param string $slug Identifier of the Monitor + * @param CheckInStatus $status The status of the check-in + * @param int|float|null $duration The duration of the check-in + * @param MonitorConfig|null $monitorConfig Configuration of the Monitor + * @param string|null $checkInId A check-in ID from the previous check-in */ -function captureCheckIn(string $slug, CheckInStatus $status, $duration = null, ?MonitorConfig $monitorConfig = null, ?string $checkInId = null, ?IsolationScope $scope = null): ?string +function captureCheckIn(string $slug, CheckInStatus $status, $duration = null, ?MonitorConfig $monitorConfig = null, ?string $checkInId = null): ?string { - return EventRecorder::captureCheckIn($slug, $status, $duration, $monitorConfig, $checkInId, $scope); + return EventRecorder::captureCheckIn($slug, $status, $duration, $monitorConfig, $checkInId); } /** diff --git a/tests/FunctionsTest.php b/tests/FunctionsTest.php index 7471b9780..c0e597a4f 100644 --- a/tests/FunctionsTest.php +++ b/tests/FunctionsTest.php @@ -192,27 +192,6 @@ public function testCaptureEvent(): void $this->assertSame($event->getId(), $scope->getLastEventId()); } - public function testCaptureEventWithExplicitScope(): void - { - $event = Event::createEvent(); - $eventId = $event->getId(); - $client = $this->createMock(ClientInterface::class); - $currentScope = $this->setClientAndIsolationScope($this->createMock(ClientInterface::class)); - $scope = new IsolationScope(); - $scope->setTag('scope', 'isolation'); - $scope->setTag('isolation', 'yes'); - $scope->setClient($client); - - $client->expects($this->once()) - ->method('captureEvent') - ->with($event, null, $this->captureScopeConstraint($scope)) - ->willReturn($eventId); - - $this->assertSame($eventId, captureEvent($event, null, $scope)); - $this->assertSame($eventId, $scope->getLastEventId()); - $this->assertNull($currentScope->getLastEventId()); - } - /** * @dataProvider captureLastErrorDataProvider */