• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

FriendsOfOpenTelemetry / opentelemetry-bundle / 12749780698

13 Jan 2025 02:51PM UTC coverage: 88.509% (-0.3%) from 88.791%
12749780698

Pull #107

github

web-flow
Merge 446412ad1 into 0b41a5c51
Pull Request #107: refactor(DependencyInjection): move configurate in compiler passes

71 of 92 new or added lines in 11 files covered. (77.17%)

2018 of 2280 relevant lines covered (88.51%)

6.89 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

77.78
/src/DependencyInjection/Compiler/HttpClientInstrumentationPass.php
1
<?php
2

3
namespace FriendsOfOpenTelemetry\OpenTelemetryBundle\DependencyInjection\Compiler;
4

5
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\Reference;
8
use Symfony\Component\HttpClient\HttpClient;
9

10
class HttpClientInstrumentationPass implements CompilerPassInterface
11
{
12
    public function process(ContainerBuilder $container): void
13
    {
14
        if (false === $container->hasParameter('open_telemetry.instrumentation.http_client.tracing.enabled')
8✔
15
            || false === $container->getParameter('open_telemetry.instrumentation.http_client.tracing.enabled')) {
8✔
16
            $container->removeDefinition('open_telemetry.instrumentation.http_client.trace.client');
6✔
17
            return;
6✔
18
        }
19

20
        if (!class_exists(HttpClient::class)) {
2✔
NEW
21
            throw new \LogicException('Http client instrumentation cannot be enabled because the symfony/http-client package is not installed.');
×
22
        }
23

24
        $decoratedService = $this->getDecoratedService($container);
2✔
25
        if (null === $decoratedService) {
2✔
NEW
26
            $container->removeDefinition('open_telemetry.instrumentation.http_client.trace.client');
×
27

NEW
28
            return;
×
29
        }
30

31
        $container->getDefinition('open_telemetry.instrumentation.http_client.trace.client')
2✔
32
            ->setArgument('$client', new Reference('.inner'))
2✔
33
            ->setDecoratedService($decoratedService[0], null, $decoratedService[1]);
2✔
34
    }
35

36
    /**
37
     * @return array{string, int}|null
38
     */
39
    private function getDecoratedService(ContainerBuilder $container): ?array
40
    {
41
        if ($container->hasDefinition('http_client.transport')) {
2✔
42
            return ['http_client.transport', -15];
1✔
43
        }
44

45
        if ($container->hasDefinition('http_client')) {
1✔
46
            return ['http_client', 15];
1✔
47
        }
48

49
        return null;
×
50
    }
51
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc