Skip to content

Commit 1d6ade7

Browse files
committed
Remove redundant event listener
1 parent 328dac6 commit 1d6ade7

File tree

2 files changed

+7
-28
lines changed

2 files changed

+7
-28
lines changed

src/Bridge/ExceptionListener.php

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

44
namespace Jaeger\Symfony\Bridge;
55

6-
use Jaeger\Span\SpanManagerInterface;
6+
use Jaeger\Span\SpanAwareInterface;
77
use Jaeger\Tag\ErrorTag;
88
use Jaeger\Tracer\TracerInterface;
99
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
1010
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
1111
use Symfony\Component\HttpKernel\Event\RequestEvent;
12-
use Symfony\Component\HttpKernel\Event\TerminateEvent;
1312
use Symfony\Component\HttpKernel\HttpKernelInterface;
1413

1514
class ExceptionListener implements EventSubscriberInterface
@@ -21,7 +20,7 @@ class ExceptionListener implements EventSubscriberInterface
2120

2221
public function __construct(
2322
TracerInterface $tracer,
24-
SpanManagerInterface $spanManager,
23+
SpanAwareInterface $spanManager,
2524
GlobalSpanHandler $globalSpanHandler
2625
) {
2726
$this->tracer = $tracer;
@@ -35,40 +34,25 @@ public static function getSubscribedEvents(): array
3534
return [
3635
ExceptionEvent::class => ['onKernelException', 0],
3736
RequestEvent::class => ['onRequest', 28],
38-
TerminateEvent::class => ['onTerminate', 4097],
3937
];
4038
}
4139

4240
public function onKernelException(ExceptionEvent $event): void
4341
{
44-
if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
45-
return;
46-
}
47-
4842
$span = $this->spanManager->getSpan();
4943

50-
if (null !== $span) {
51-
$span->addTag(new ErrorTag());
52-
$this->exceptionExist = true;
53-
}
54-
}
55-
56-
public function onRequest(RequestEvent $event): void
57-
{
58-
if (HttpKernelInterface::MASTER_REQUEST === $event->getRequestType()) {
44+
if (null === $span) {
5945
return;
6046
}
6147

62-
if ($this->exceptionExist) {
63-
$span = $this->spanManager->getSpan();
64-
$span->addTag(new ErrorTag());
65-
}
48+
$span->addTag(new ErrorTag());
49+
$this->exceptionExist = true;
6650
}
6751

68-
public function onTerminate(): void
52+
public function onRequest(RequestEvent $event): void
6953
{
7054
if ($this->exceptionExist) {
71-
$this->globalSpanHandler->addTag(new ErrorTag());
55+
$this->spanManager->getSpan()->addTag(new ErrorTag());
7256
}
7357
}
7458
}

src/Bridge/GlobalSpanHandler.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,4 @@ public function flush(): void
6565
$this->span->finish((int)$this->durationUsec);
6666
$this->span = $this->durationUsec = null;
6767
}
68-
69-
public function addTag(Tag $tag): void
70-
{
71-
$this->span->addTag($tag);
72-
}
7368
}

0 commit comments

Comments
 (0)