Skip to content

Commit 94e6a7f

Browse files
committed
Limit supported versions to Symfony 4.3 only
1 parent 7f987fd commit 94e6a7f

24 files changed

+147
-263
lines changed

composer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
},
99
"require": {
1010
"php": ">=7.1",
11-
"symfony/event-dispatcher": "^2.6 || ^3.4 || ^4",
12-
"symfony/console": "^2.6 || ^3.4 || ^4",
13-
"symfony/config": "^2.6 || ^3.4 || ^4",
14-
"symfony/http-kernel": "^2.6 || ^3.4 || ^4",
15-
"symfony/dependency-injection": "^2.6 || ^3.4 || ^4",
16-
"code-tool/jaeger-client-php": "^2.12.2"
11+
"symfony/event-dispatcher": "^4.3",
12+
"symfony/console": "^4.3",
13+
"symfony/config": "^4.3",
14+
"symfony/http-kernel": "^4.3",
15+
"symfony/dependency-injection": "^4.3",
16+
"code-tool/jaeger-client-php": "^3"
1717
},
1818
"require-dev": {
1919
"phpunit/phpunit": "@stable"

src/Bridge/AppStartSpanListener.php

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,11 @@
55

66
use Jaeger\Symfony\Tag\SymfonyComponentTag;
77
use Jaeger\Symfony\Tag\SymfonyVersionTag;
8-
use Jaeger\Symfony\Tag\TimeMicroTag;
9-
use Jaeger\Symfony\Tag\TimeSourceTag;
10-
use Jaeger\Symfony\Tag\TimeValueTag;
118
use Jaeger\Tag\SpanKindServerTag;
129
use Jaeger\Tracer\TracerInterface;
1310
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
14-
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
11+
use Symfony\Component\HttpKernel\Event\RequestEvent;
1512
use Symfony\Component\HttpKernel\HttpKernelInterface;
16-
use Symfony\Component\HttpKernel\KernelEvents;
1713

1814
class AppStartSpanListener implements EventSubscriberInterface
1915
{
@@ -24,32 +20,24 @@ public function __construct(TracerInterface $tracer)
2420
$this->tracer = $tracer;
2521
}
2622

27-
public static function getSubscribedEvents()
23+
public static function getSubscribedEvents(): array
2824
{
29-
return [
30-
KernelEvents::REQUEST => ['onRequest', -1],
31-
];
25+
return [RequestEvent::class => ['onRequest', -1],];
3226
}
3327

34-
public function onRequest(GetResponseEvent $event)
28+
public function onRequest(RequestEvent $event)
3529
{
3630
$request = $event->getRequest();
3731
if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
3832
return $this;
3933
}
40-
$source = $request->server->has('REQUEST_TIME_FLOAT') ? 'header' : 'microtime';
41-
$value = $request->server->get('REQUEST_TIME_FLOAT', microtime(true));
42-
$startTime = (int)($value * 1000000);
43-
$this->tracer->finish(
44-
$this->tracer->start('symfony.start')
45-
->addTag(new SpanKindServerTag())
46-
->addTag(new SymfonyComponentTag())
47-
->addTag(new SymfonyVersionTag())
48-
->addTag(new TimeSourceTag($source))
49-
->addTag(new TimeValueTag($value))
50-
->addTag(new TimeMicroTag($startTime))
51-
->start($startTime)
52-
);
34+
$this->tracer
35+
->start('symfony.start')
36+
->addTag(new SpanKindServerTag())
37+
->addTag(new SymfonyComponentTag())
38+
->addTag(new SymfonyVersionTag())
39+
->start(1000000 * $request->server->get('REQUEST_TIME_FLOAT', microtime(true)))
40+
->finish();
5341

5442
return $this;
5543
}

src/Bridge/BackgroundSpanHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function flush(): BackgroundSpanHandler
4949
if (null === $this->span) {
5050
return $this;
5151
}
52-
$this->tracer->finish($this->span);
52+
$this->span->finish();
5353

5454
return $this;
5555
}

src/Bridge/BackgroundStartListener.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
namespace Jaeger\Symfony\Bridge;
55

66
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
7-
use Symfony\Component\HttpKernel\Event\PostResponseEvent;
8-
use Symfony\Component\HttpKernel\KernelEvents;
7+
use Symfony\Component\HttpKernel\Event\TerminateEvent;
98

109
class BackgroundStartListener implements EventSubscriberInterface
1110
{
@@ -16,15 +15,13 @@ public function __construct(BackgroundSpanHandler $handler)
1615
$this->handler = $handler;
1716
}
1817

19-
public static function getSubscribedEvents()
18+
public static function getSubscribedEvents(): array
2019
{
21-
return [KernelEvents::TERMINATE => ['onTerminate', 16384],];
20+
return [TerminateEvent::class => ['onTerminate', 16384],];
2221
}
2322

24-
public function onTerminate(PostResponseEvent $event)
23+
public function onTerminate(TerminateEvent $event): void
2524
{
2625
$this->handler->start($event->getRequest());
27-
28-
return $this;
2926
}
3027
}

src/Bridge/ContextListener.php

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55

66
use Jaeger\Symfony\Context\Extractor\ContextExtractorInterface;
77
use Jaeger\Tracer\InjectableInterface;
8-
use Symfony\Component\Console\ConsoleEvents;
8+
use Symfony\Component\Console\Event\ConsoleCommandEvent;
99
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
10-
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
11-
use Symfony\Component\HttpKernel\KernelEvents;
10+
use Symfony\Component\HttpKernel\Event\RequestEvent;
1211

1312
class ContextListener implements EventSubscriberInterface
1413
{
@@ -24,35 +23,32 @@ public function __construct(
2423
$this->extractor = $extractor;
2524
}
2625

27-
public static function getSubscribedEvents()
26+
public static function getSubscribedEvents(): array
2827
{
2928
return [
30-
ConsoleEvents::COMMAND => ['onCommand', 8192],
31-
KernelEvents::REQUEST => ['onRequest', 8192],
29+
ConsoleCommandEvent::class => ['onCommand', 8192],
30+
RequestEvent::class => ['onRequest', 8192],
3231
];
3332
}
3433

35-
public function onCommand()
34+
public function onCommand(): void
3635
{
37-
return $this->inject();
36+
$this->inject();
3837
}
3938

40-
public function inject(): ContextListener
39+
public function inject(): void
4140
{
4241
if (null === ($context = $this->extractor->extract())) {
43-
return $this;
42+
return;
4443
}
4544
$this->injectable->assign($context);
46-
47-
return $this;
4845
}
4946

50-
public function onRequest(GetResponseEvent $event)
47+
public function onRequest(RequestEvent $event): void
5148
{
5249
if (false === $event->isMasterRequest()) {
53-
return $this;
50+
return;
5451
}
55-
56-
return $this->inject();
52+
$this->inject();
5753
}
5854
}

src/Bridge/DebugListener.php

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,67 +5,55 @@
55

66
use Jaeger\Symfony\Debug\Extractor\DebugExtractorInterface;
77
use Jaeger\Tracer\DebuggableInterface;
8-
use Symfony\Component\Console\ConsoleEvents;
8+
use Symfony\Component\Console\Event\ConsoleCommandEvent;
9+
use Symfony\Component\Console\Event\ConsoleTerminateEvent;
910
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
10-
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
11-
use Symfony\Component\HttpKernel\KernelEvents;
11+
use Symfony\Component\HttpKernel\Event\RequestEvent;
12+
use Symfony\Component\HttpKernel\Event\TerminateEvent;
1213

1314
class DebugListener implements EventSubscriberInterface
1415
{
1516
private $debuggable;
1617

1718
private $extractor;
1819

19-
/**
20-
* DebugListener constructor.
21-
*
22-
* @param DebuggableInterface $debuggable
23-
* @param DebugExtractorInterface $extractor
24-
*/
2520
public function __construct(DebuggableInterface $debuggable, DebugExtractorInterface $extractor)
2621
{
2722
$this->debuggable = $debuggable;
2823
$this->extractor = $extractor;
2924
}
3025

31-
public static function getSubscribedEvents()
26+
public static function getSubscribedEvents(): array
3227
{
3328
return [
34-
ConsoleEvents::COMMAND => ['onCommand', 8192],
35-
KernelEvents::REQUEST => ['onRequest', 8192],
36-
ConsoleEvents::TERMINATE => ['onTerminate'],
37-
KernelEvents::TERMINATE => ['onTerminate'],
29+
ConsoleCommandEvent::class => ['onCommand', 8192],
30+
RequestEvent::class => ['onRequest', 8192],
31+
ConsoleTerminateEvent::class => ['onTerminate'],
32+
TerminateEvent::class => ['onTerminate'],
3833
];
3934
}
4035

41-
public function onTerminate()
36+
public function onTerminate(): void
4237
{
4338
$this->debuggable->disable();
44-
45-
return $this;
4639
}
4740

48-
public function onCommand()
41+
public function onCommand(): void
4942
{
5043
if ('' === ($debugId = $this->extractor->getDebug())) {
51-
return $this;
44+
return;
5245
}
5346
$this->debuggable->enable($debugId);
54-
55-
return $this;
5647
}
5748

58-
public function onRequest(GetResponseEvent $event)
49+
public function onRequest(RequestEvent $event)
5950
{
6051
if (false === $event->isMasterRequest()) {
61-
return $this;
52+
return;
6253
}
63-
6454
if ('' === ($debugId = $this->extractor->getDebug())) {
65-
return $this;
55+
return;
6656
}
6757
$this->debuggable->enable($debugId);
68-
69-
return $this;
7058
}
7159
}

src/Bridge/GlobalSpanHandler.php

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,32 +41,27 @@ public function start(Request $request): GlobalSpanHandler
4141
new HttpUriTag($request->getRequestUri()),
4242
new SpanKindServerTag(),
4343
new SymfonyComponentTag(),
44-
new SymfonyVersionTag()
44+
new SymfonyVersionTag(),
4545
]
46-
)->start((int)(1000000 * $request->server->get('REQUEST_TIME_FLOAT', microtime(true))));
46+
)->start(1000000 * $request->server->get('REQUEST_TIME_FLOAT', microtime(true)));
4747

4848
return $this;
4949
}
5050

51-
public function finish(): GlobalSpanHandler
51+
public function finish(): void
5252
{
5353
if (null === $this->span) {
54-
return $this;
54+
return;
5555
}
56-
$this->durationUsec = (int)(microtime(true) * 1000000 - $this->span->startTime);
57-
58-
return $this;
56+
$this->durationUsec = microtime(true) * 1000000 - $this->span->startTime;
5957
}
6058

61-
public function flush(): GlobalSpanHandler
59+
public function flush(): void
6260
{
6361
if (null === $this->span || null === $this->durationUsec) {
64-
return $this;
62+
return;
6563
}
66-
67-
$this->tracer->finish($this->span, $this->durationUsec);
64+
$this->span->finish($this->durationUsec);
6865
$this->span = $this->durationUsec = null;
69-
70-
return $this;
7166
}
7267
}

src/Bridge/GlobalSpanListener.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
namespace Jaeger\Symfony\Bridge;
55

66
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
7-
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
7+
use Symfony\Component\HttpKernel\Event\RequestEvent;
8+
use Symfony\Component\HttpKernel\Event\TerminateEvent;
89
use Symfony\Component\HttpKernel\HttpKernelInterface;
9-
use Symfony\Component\HttpKernel\KernelEvents;
1010

1111
class GlobalSpanListener implements EventSubscriberInterface
1212
{
@@ -20,8 +20,8 @@ public function __construct(GlobalSpanHandler $handler)
2020
public static function getSubscribedEvents()
2121
{
2222
return [
23-
KernelEvents::REQUEST => ['onRequest', 30],
24-
KernelEvents::TERMINATE => ['onTerminate', 4096],
23+
RequestEvent::class => ['onRequest', 30],
24+
TerminateEvent::class => ['onTerminate', 4096],
2525
];
2626
}
2727

@@ -32,7 +32,7 @@ public function onTerminate()
3232
return $this;
3333
}
3434

35-
public function onRequest(GetResponseEvent $event)
35+
public function onRequest(RequestEvent $event)
3636
{
3737
if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
3838
return $this;

src/Bridge/HandlerFlushListener.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
namespace Jaeger\Symfony\Bridge;
55

66
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
7-
use Symfony\Component\HttpKernel\KernelEvents;
7+
use Symfony\Component\HttpKernel\Event\TerminateEvent;
88

99
class HandlerFlushListener implements EventSubscriberInterface
1010
{
@@ -20,7 +20,7 @@ public function __construct(BackgroundSpanHandler $backgroundHandler, GlobalSpan
2020

2121
public static function getSubscribedEvents()
2222
{
23-
return [KernelEvents::TERMINATE => ['onTerminate', -16384],];
23+
return [TerminateEvent::class => ['onTerminate', -16384],];
2424
}
2525

2626
public function onTerminate()

0 commit comments

Comments
 (0)