-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix wrapping of the DBAL driver connection when implementing the `Doc…
…trine\DBAL\Driver\ServerInfoAwareConnection` interface (#567)
- Loading branch information
Showing
17 changed files
with
751 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/Tracing/Doctrine/DBAL/TracingDriverConnectionFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sentry\SentryBundle\Tracing\Doctrine\DBAL; | ||
|
||
use Doctrine\DBAL\Driver\Connection; | ||
use Doctrine\DBAL\Driver\ServerInfoAwareConnection; | ||
use Doctrine\DBAL\Platforms\AbstractPlatform; | ||
use Sentry\State\HubInterface; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final class TracingDriverConnectionFactory implements TracingDriverConnectionFactoryInterface | ||
{ | ||
/** | ||
* @var HubInterface The current hub | ||
*/ | ||
private $hub; | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @param HubInterface $hub The current hub | ||
*/ | ||
public function __construct(HubInterface $hub) | ||
{ | ||
$this->hub = $hub; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function create(Connection $connection, AbstractPlatform $databasePlatform, array $params): TracingDriverConnectionInterface | ||
{ | ||
$tracingDriverConnection = new TracingDriverConnection( | ||
$this->hub, | ||
$connection, | ||
$databasePlatform->getName(), | ||
$params | ||
); | ||
|
||
if ($connection instanceof ServerInfoAwareConnection) { | ||
$tracingDriverConnection = new TracingServerInfoAwareDriverConnection($tracingDriverConnection); | ||
} | ||
|
||
return $tracingDriverConnection; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/Tracing/Doctrine/DBAL/TracingDriverConnectionFactoryInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sentry\SentryBundle\Tracing\Doctrine\DBAL; | ||
|
||
use Doctrine\DBAL\Driver\Connection; | ||
use Doctrine\DBAL\Platforms\AbstractPlatform; | ||
|
||
interface TracingDriverConnectionFactoryInterface | ||
{ | ||
/** | ||
* Creates an instance of a driver connection which is decorated to trace | ||
* the performances of the queries. | ||
* | ||
* @param Connection $connection The connection to wrap | ||
* @param AbstractPlatform $databasePlatform The database platform | ||
* @param array<string, mixed> $params The params of the connection | ||
*/ | ||
public function create(Connection $connection, AbstractPlatform $databasePlatform, array $params): TracingDriverConnectionInterface; | ||
} |
12 changes: 12 additions & 0 deletions
12
src/Tracing/Doctrine/DBAL/TracingDriverConnectionInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sentry\SentryBundle\Tracing\Doctrine\DBAL; | ||
|
||
use Doctrine\DBAL\Driver\Connection; | ||
|
||
interface TracingDriverConnectionInterface extends Connection | ||
{ | ||
public function getWrappedConnection(): Connection; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.