Skip to content

Commit 2e470a1

Browse files
authored
fix transactions not being sent after response has been sent to client in a fastcgi environment (#45)
* fix transactions not being sent after response has been sent to client in a fastcgi environment * fix CI * fix cs
1 parent a2b7336 commit 2e470a1

File tree

3 files changed

+4
-10
lines changed

3 files changed

+4
-10
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
php-version: [ '8.2', '8.3', '8.4', '8.5' ]
2323
dependencies: ['highest']
2424
include:
25-
- php-version: '8.1'
25+
- php-version: '8.2'
2626
dependencies: 'lowest'
2727

2828
steps:
@@ -51,7 +51,7 @@ jobs:
5151
fi
5252
5353
- name: Code Coverage Report
54-
if: success() && matrix.php-version == '8.1'
54+
if: success() && matrix.php-version == '8.2'
5555
uses: codecov/codecov-action@v5
5656

5757
cs-stan:

src/Log/Engines/SentryLog.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
namespace CakeSentry\Log\Engines;
55

66
use Cake\Event\EventManager;
7-
use Cake\Http\Server;
87
use Cake\Log\Engine\BaseLog;
98
use Psr\Log\LogLevel;
109
use Sentry\Logs\Logs;
@@ -22,11 +21,7 @@ public function __construct(array $config = [])
2221
parent::__construct($config);
2322

2423
// Send the logs to sentry after the client has received the response
25-
if (
26-
PHP_SAPI !== 'cli' &&
27-
function_exists('fastcgi_finish_request') &&
28-
method_exists(Server::class, 'terminate')
29-
) {
24+
if (PHP_SAPI !== 'cli' && function_exists('fastcgi_finish_request')) {
3025
$this->logsWillBeFlushed = true;
3126
EventManager::instance()->on('Server.terminate', function (): void {
3227
Logs::getInstance()->flush();

src/Middleware/CakeSentryPerformanceMiddleware.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use Cake\Database\Driver;
1717
use Cake\Datasource\ConnectionManager;
1818
use Cake\Event\EventManager;
19-
use Cake\Http\Server;
2019
use CakeSentry\Database\Log\CakeSentryLog;
2120
use CakeSentry\Event\CacheEventListener;
2221
use CakeSentry\Event\HttpEventListener;
@@ -101,7 +100,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
101100

102101
$transaction->setHttpStatus($response->getStatusCode());
103102

104-
if (function_exists('fastcgi_finish_request') && method_exists(Server::class, 'terminate')) {
103+
if (function_exists('fastcgi_finish_request')) {
105104
// Send the transaction to sentry after the client has received the response
106105
EventManager::instance()->on('Server.terminate', function () use ($transaction): void {
107106
$transaction->finish();

0 commit comments

Comments
 (0)