forked from getsentry/sentry-symfony
/
HttpClientTracingPass.php
37 lines (32 loc) · 1.21 KB
/
HttpClientTracingPass.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
declare(strict_types=1);
namespace Sentry\SentryBundle\DependencyInjection\Compiler;
use Sentry\SentryBundle\Tracing\HttpClient\TraceableHttpClient;
use Sentry\State\HubInterface;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
final class HttpClientTracingPass implements CompilerPassInterface
{
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container): void
{
if (
!$container->getParameter('sentry.tracing.enabled')
|| !$container->getParameter('sentry.tracing.http_client.enabled')
) {
return;
}
foreach ($container->findTaggedServiceIds('http_client.client') as $id => $tags) {
$container->register('.sentry.traceable.' . $id, TraceableHttpClient::class)
->setArguments([
new Reference('.sentry.traceable.' . $id . '.inner'),
new Reference(HubInterface::class),
])
->addTag('kernel.reset', ['method' => 'reset'])
->setDecoratedService($id);
}
}
}