Skip to content

Commit 9fa4ee9

Browse files
committed
Fix context propagation
1 parent e4cc860 commit 9fa4ee9

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

src/Context/Extractor/HeaderContextExtractor.php

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

1414
class HeaderContextExtractor implements ContextExtractorInterface, EventSubscriberInterface
@@ -44,24 +44,23 @@ public function extract(): ?SpanContext
4444
return $this->context;
4545
}
4646

47-
public function onTerminate()
47+
public function onTerminate(PostResponseEvent $event)
4848
{
49+
if (false === $event->isMasterRequest()) {
50+
return $this;
51+
}
4952
$this->context = null;
5053

5154
return $this;
5255
}
5356

5457
public function onRequest(GetResponseEvent $event)
5558
{
56-
$request = $event->getRequest();
57-
if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
58-
$this->context = null;
59-
59+
if (false === $event->isMasterRequest()) {
6060
return $this;
6161
}
62-
63-
if (HttpKernelInterface::MASTER_REQUEST === $event->getRequestType()
64-
&& $request->headers->has($this->headerName)
62+
$request = $event->getRequest();
63+
if ($request->headers->has($this->headerName)
6564
&& ($context = $this->registry[$this->format]->decode($request->headers->get($this->headerName)))) {
6665
$this->context = $context;
6766

src/Debug/Extractor/CookieDebugExtractor.php

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

66
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
77
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
8-
use Symfony\Component\HttpKernel\HttpKernelInterface;
8+
use Symfony\Component\HttpKernel\Event\PostResponseEvent;
99
use Symfony\Component\HttpKernel\KernelEvents;
1010

1111
class CookieDebugExtractor implements DebugExtractorInterface, EventSubscriberInterface
@@ -21,7 +21,7 @@ public function __construct(string $cookieName)
2121

2222
public function onRequest(GetResponseEvent $event)
2323
{
24-
if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
24+
if (false === $event->isMasterRequest()) {
2525
return $this;
2626
}
2727

@@ -35,8 +35,11 @@ public function onRequest(GetResponseEvent $event)
3535
return $this;
3636
}
3737

38-
public function onTerminate()
38+
public function onTerminate(PostResponseEvent $event)
3939
{
40+
if (false === $event->isMasterRequest()) {
41+
return $this;
42+
}
4043
$this->debugId = '';
4144

4245
return $this;

0 commit comments

Comments
 (0)