77use Jaeger \Tracer \DebuggableInterface ;
88use Symfony \Component \Console \ConsoleEvents ;
99use Symfony \Component \EventDispatcher \EventSubscriberInterface ;
10+ use Symfony \Component \HttpKernel \Event \GetResponseEvent ;
1011use Symfony \Component \HttpKernel \KernelEvents ;
1112
1213class 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