Skip to content

Commit 996515f

Browse files
committed
Merge branch '2.0.x' into 1.0.x
# Conflicts: # src/Bridge/DebugListener.php # src/Context/Extractor/HeaderContextExtractor.php
2 parents bb56d15 + a210aeb commit 996515f

File tree

3 files changed

+37
-15
lines changed

3 files changed

+37
-15
lines changed

src/Bridge/DebugListener.php

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Jaeger\Tracer\DebuggableInterface;
66
use Symfony\Component\Console\ConsoleEvents;
77
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
8+
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
89
use Symfony\Component\HttpKernel\KernelEvents;
910

1011
class DebugListener implements EventSubscriberInterface
@@ -28,8 +29,8 @@ public function __construct(DebuggableInterface $debuggable, DebugExtractorInter
2829
public static function getSubscribedEvents()
2930
{
3031
return [
31-
ConsoleEvents::COMMAND => ['onStart', 8192],
32-
KernelEvents::REQUEST => ['onStart', 8192],
32+
ConsoleEvents::COMMAND => ['onCommand', 8192],
33+
KernelEvents::REQUEST => ['onRequest', 8192],
3334
ConsoleEvents::TERMINATE => ['onTerminate'],
3435
KernelEvents::TERMINATE => ['onTerminate'],
3536
];
@@ -48,7 +49,7 @@ public function onTerminate()
4849
/**
4950
* @return DebugListener
5051
*/
51-
public function onStart()
52+
public function onCommand()
5253
{
5354
if ('' === ($debugId = $this->extractor->getDebug())) {
5455
return $this;
@@ -57,4 +58,23 @@ public function onStart()
5758

5859
return $this;
5960
}
61+
62+
/**
63+
* @param GetResponseEvent $event
64+
*
65+
* @return DebugListener
66+
*/
67+
public function onRequest(GetResponseEvent $event)
68+
{
69+
if (false === $event->isMasterRequest()) {
70+
return $this;
71+
}
72+
73+
if ('' === ($debugId = $this->extractor->getDebug())) {
74+
return $this;
75+
}
76+
$this->debuggable->enable($debugId);
77+
78+
return $this;
79+
}
6080
}

src/Context/Extractor/HeaderContextExtractor.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use Jaeger\Span\Context\SpanContext;
77
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
88
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
9-
use Symfony\Component\HttpKernel\HttpKernelInterface;
9+
use Symfony\Component\HttpKernel\Event\PostResponseEvent;
1010
use Symfony\Component\HttpKernel\KernelEvents;
1111

1212
class HeaderContextExtractor implements ContextExtractorInterface, EventSubscriberInterface
@@ -55,8 +55,11 @@ public static function getSubscribedEvents()
5555
/**
5656
* @return HeaderContextExtractor
5757
*/
58-
public function onTerminate()
58+
public function onTerminate(PostResponseEvent $event)
5959
{
60+
if (false === $event->isMasterRequest()) {
61+
return $this;
62+
}
6063
$this->context = null;
6164

6265
return $this;
@@ -69,15 +72,11 @@ public function onTerminate()
6972
*/
7073
public function onRequest(GetResponseEvent $event)
7174
{
72-
$request = $event->getRequest();
73-
if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
74-
$this->context = null;
75-
75+
if (false === $event->isMasterRequest()) {
7676
return $this;
7777
}
78-
79-
if (HttpKernelInterface::MASTER_REQUEST === $event->getRequestType()
80-
&& $request->headers->has($this->headerName)
78+
$request = $event->getRequest();
79+
if ($request->headers->has($this->headerName)
8180
&& ($context = $this->registry[$this->format]->decode($request->headers->get($this->headerName)))) {
8281
$this->context = $context;
8382

src/Debug/Extractor/CookieDebugExtractor.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
55
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
6-
use Symfony\Component\HttpKernel\HttpKernelInterface;
6+
use Symfony\Component\HttpKernel\Event\PostResponseEvent;
77
use Symfony\Component\HttpKernel\KernelEvents;
88

99
class CookieDebugExtractor implements DebugExtractorInterface, EventSubscriberInterface
@@ -24,7 +24,7 @@ public function __construct($cookieName)
2424

2525
public function onRequest(GetResponseEvent $event)
2626
{
27-
if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
27+
if (false === $event->isMasterRequest()) {
2828
return $this;
2929
}
3030

@@ -38,8 +38,11 @@ public function onRequest(GetResponseEvent $event)
3838
return $this;
3939
}
4040

41-
public function onTerminate()
41+
public function onTerminate(PostResponseEvent $event)
4242
{
43+
if (false === $event->isMasterRequest()) {
44+
return $this;
45+
}
4346
$this->debugId = '';
4447

4548
return $this;

0 commit comments

Comments
 (0)