Skip to content

Commit b12d386

Browse files
committed
fix
1 parent 8eb6ae7 commit b12d386

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

src/SentrySdk.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@ public static function flush(): void
144144
{
145145
Logs::getInstance()->flush();
146146
TraceMetrics::getInstance()->flush();
147+
148+
$client = self::getCurrentHub()->getClient();
149+
150+
if ($client !== null) {
151+
$client->flush();
152+
}
147153
}
148154

149155
private static function getRuntimeContextManager(): RuntimeContextManager

tests/SentrySdkTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,20 @@ public function testEndContextFlushesClientTransportWithOptionalTimeout(): void
129129
SentrySdk::endContext(12);
130130
}
131131

132+
public function testFlushFlushesClientTransport(): void
133+
{
134+
/** @var ClientInterface&MockObject $client */
135+
$client = $this->createMock(ClientInterface::class);
136+
$client->expects($this->once())
137+
->method('flush')
138+
->with(null)
139+
->willReturn(new Result(ResultStatus::success()));
140+
141+
SentrySdk::init()->bindClient($client);
142+
143+
SentrySdk::flush();
144+
}
145+
132146
public function testWithContextReturnsCallbackResultAndRestoresGlobalHub(): void
133147
{
134148
SentrySdk::init();

0 commit comments

Comments
 (0)