-
-
Notifications
You must be signed in to change notification settings - Fork 454
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #954 from ottaviano/backtrace-logger
[Profiling] Add query backtrace data
- Loading branch information
Showing
11 changed files
with
128 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace Doctrine\Bundle\DoctrineBundle\Dbal\Logging; | ||
|
||
use Doctrine\DBAL\Logging\DebugStack; | ||
|
||
final class BacktraceLogger extends DebugStack | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function startQuery($sql, ?array $params = null, ?array $types = null) : void | ||
{ | ||
parent::startQuery($sql, $params, $types); | ||
|
||
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); | ||
|
||
// skip first since it's always the current method | ||
array_shift($backtrace); | ||
|
||
$this->queries[$this->currentQuery]['backtrace'] = $backtrace; | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace Doctrine\Bundle\DoctrineBundle\Tests\Dbal\Logging; | ||
|
||
use Doctrine\Bundle\DoctrineBundle\Dbal\Logging\BacktraceLogger; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class BacktraceLoggerTest extends TestCase | ||
{ | ||
public function testBacktraceLogged() : void | ||
{ | ||
$logger = new BacktraceLogger(); | ||
$logger->startQuery('SELECT column FROM table'); | ||
$currentQuery = current($logger->queries); | ||
self::assertSame('SELECT column FROM table', $currentQuery['sql']); | ||
self::assertNull($currentQuery['params']); | ||
self::assertNull($currentQuery['types']); | ||
self::assertCount(11, $currentQuery['backtrace']); | ||
} | ||
} |
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