Skip to content

Commit a210aeb

Browse files
committed
Split logic in debug listener
1 parent 9fa4ee9 commit a210aeb

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/Bridge/DebugListener.php

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Jaeger\Tracer\DebuggableInterface;
88
use Symfony\Component\Console\ConsoleEvents;
99
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
10+
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
1011
use Symfony\Component\HttpKernel\KernelEvents;
1112

1213
class DebugListener implements EventSubscriberInterface
@@ -30,8 +31,8 @@ public function __construct(DebuggableInterface $debuggable, DebugExtractorInter
3031
public static function getSubscribedEvents()
3132
{
3233
return [
33-
ConsoleEvents::COMMAND => ['onStart', 8192],
34-
KernelEvents::REQUEST => ['onStart', 8192],
34+
ConsoleEvents::COMMAND => ['onCommand', 8192],
35+
KernelEvents::REQUEST => ['onRequest', 8192],
3536
ConsoleEvents::TERMINATE => ['onTerminate'],
3637
KernelEvents::TERMINATE => ['onTerminate'],
3738
];
@@ -44,7 +45,7 @@ public function onTerminate()
4445
return $this;
4546
}
4647

47-
public function onStart()
48+
public function onCommand()
4849
{
4950
if ('' === ($debugId = $this->extractor->getDebug())) {
5051
return $this;
@@ -53,4 +54,18 @@ public function onStart()
5354

5455
return $this;
5556
}
57+
58+
public function onRequest(GetResponseEvent $event)
59+
{
60+
if (false === $event->isMasterRequest()) {
61+
return $this;
62+
}
63+
64+
if ('' === ($debugId = $this->extractor->getDebug())) {
65+
return $this;
66+
}
67+
$this->debuggable->enable($debugId);
68+
69+
return $this;
70+
}
5671
}

0 commit comments

Comments
 (0)