3
3
4
4
namespace Jaeger \Symfony \Bridge ;
5
5
6
- use Jaeger \Span \SpanManagerInterface ;
6
+ use Jaeger \Span \SpanAwareInterface ;
7
7
use Jaeger \Tag \ErrorTag ;
8
8
use Jaeger \Tracer \TracerInterface ;
9
9
use Symfony \Component \EventDispatcher \EventSubscriberInterface ;
10
10
use Symfony \Component \HttpKernel \Event \ExceptionEvent ;
11
11
use Symfony \Component \HttpKernel \Event \RequestEvent ;
12
- use Symfony \Component \HttpKernel \Event \TerminateEvent ;
13
12
use Symfony \Component \HttpKernel \HttpKernelInterface ;
14
13
15
14
class ExceptionListener implements EventSubscriberInterface
@@ -21,7 +20,7 @@ class ExceptionListener implements EventSubscriberInterface
21
20
22
21
public function __construct (
23
22
TracerInterface $ tracer ,
24
- SpanManagerInterface $ spanManager ,
23
+ SpanAwareInterface $ spanManager ,
25
24
GlobalSpanHandler $ globalSpanHandler
26
25
) {
27
26
$ this ->tracer = $ tracer ;
@@ -35,40 +34,25 @@ public static function getSubscribedEvents(): array
35
34
return [
36
35
ExceptionEvent::class => ['onKernelException ' , 0 ],
37
36
RequestEvent::class => ['onRequest ' , 28 ],
38
- TerminateEvent::class => ['onTerminate ' , 4097 ],
39
37
];
40
38
}
41
39
42
40
public function onKernelException (ExceptionEvent $ event ): void
43
41
{
44
- if (HttpKernelInterface::MASTER_REQUEST !== $ event ->getRequestType ()) {
45
- return ;
46
- }
47
-
48
42
$ span = $ this ->spanManager ->getSpan ();
49
43
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 ) {
59
45
return ;
60
46
}
61
47
62
- if ($ this ->exceptionExist ) {
63
- $ span = $ this ->spanManager ->getSpan ();
64
- $ span ->addTag (new ErrorTag ());
65
- }
48
+ $ span ->addTag (new ErrorTag ());
49
+ $ this ->exceptionExist = true ;
66
50
}
67
51
68
- public function onTerminate ( ): void
52
+ public function onRequest ( RequestEvent $ event ): void
69
53
{
70
54
if ($ this ->exceptionExist ) {
71
- $ this ->globalSpanHandler ->addTag (new ErrorTag ());
55
+ $ this ->spanManager -> getSpan () ->addTag (new ErrorTag ());
72
56
}
73
57
}
74
58
}
0 commit comments