/
HttpClientTracingPass.php
32 lines (27 loc) · 1.15 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
<?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)
->setDecoratedService($id)
->setArgument(0, new Reference('.sentry.traceable.' . $id . '.inner'))
->setArgument(1, new Reference(HubInterface::class))
->addTag('kernel.reset', ['method' => 'reset']);
}
}
}