Skip to content

Commit

Permalink
refactor(DependencyInjection): remove services definitions from exten…
Browse files Browse the repository at this point in the history
…sion (#124)
  • Loading branch information
gaelreyrol authored Jan 25, 2025
1 parent c280b2c commit cf88e33
Show file tree
Hide file tree
Showing 21 changed files with 226 additions and 478 deletions.
11 changes: 1 addition & 10 deletions src/DependencyInjection/Compiler/CacheInstrumentationPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace FriendsOfOpenTelemetry\OpenTelemetryBundle\DependencyInjection\Compiler;

use Symfony\Component\Cache\CacheItem;
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand All @@ -13,18 +12,10 @@ class CacheInstrumentationPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container): void
{
if (false === $container->hasParameter('open_telemetry.instrumentation.cache.tracing.enabled')
|| false === $container->getParameter('open_telemetry.instrumentation.cache.tracing.enabled')) {
$container->removeDefinition('open_telemetry.instrumentation.cache.trace.tag_aware_adapter');
$container->removeDefinition('open_telemetry.instrumentation.cache.trace.adapter');

if (!$container->getParameter('open_telemetry.instrumentation.cache.tracing.enabled')) {
return;
}

if (!class_exists(CacheItem::class)) {
throw new \LogicException('Cache instrumentation cannot be enabled because the symfony/cache package is not installed.');
}

foreach ($container->findTaggedServiceIds('cache.pool') as $serviceId => $tags) {
$cachePoolDefinition = $container->getDefinition($serviceId);
if ($cachePoolDefinition->isAbstract()) {
Expand Down
19 changes: 0 additions & 19 deletions src/DependencyInjection/Compiler/ConsoleInstrumentationPass.php

This file was deleted.

25 changes: 0 additions & 25 deletions src/DependencyInjection/Compiler/DoctrineInstrumentationPass.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,15 @@
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\HttpClient\HttpClient;

class HttpClientInstrumentationPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container): void
{
if (false === $container->hasParameter('open_telemetry.instrumentation.http_client.tracing.enabled')
|| false === $container->getParameter('open_telemetry.instrumentation.http_client.tracing.enabled')) {
$container->removeDefinition('open_telemetry.instrumentation.http_client.trace.client');

if (!$container->getParameter('open_telemetry.instrumentation.http_client.tracing.enabled')) {
return;
}

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

$decoratedService = $this->getDecoratedService($container);
if (null === $decoratedService) {
$container->removeDefinition('open_telemetry.instrumentation.http_client.trace.client');
Expand Down
20 changes: 0 additions & 20 deletions src/DependencyInjection/Compiler/HttpKernelInstrumentationPass.php

This file was deleted.

27 changes: 0 additions & 27 deletions src/DependencyInjection/Compiler/MailerInstrumentationPass.php

This file was deleted.

34 changes: 0 additions & 34 deletions src/DependencyInjection/Compiler/MessengerInstrumentationPass.php

This file was deleted.

4 changes: 2 additions & 2 deletions src/DependencyInjection/Compiler/TracerLocatorPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ public function process(ContainerBuilder $container): void
$tracers = $container->findTaggedServiceIds('open_telemetry.tracer');

if (0 < count($tracers)) {
if ($container->has('open_telemetry.instrumentation.console.trace.event_subscriber')) {
if ($container->hasDefinition('open_telemetry.instrumentation.console.trace.event_subscriber')) {
$traceableConsoleEventSubscriber = $container->getDefinition('open_telemetry.instrumentation.console.trace.event_subscriber');
$this->setTracerLocatorArgument($container, $traceableConsoleEventSubscriber, $tracers);
}
if ($container->has('open_telemetry.instrumentation.http_kernel.trace.event_subscriber')) {
if ($container->hasDefinition('open_telemetry.instrumentation.http_kernel.trace.event_subscriber')) {
$traceableHttpKernelEventSubscriber = $container->getDefinition('open_telemetry.instrumentation.http_kernel.trace.event_subscriber');
$this->setTracerLocatorArgument($container, $traceableHttpKernelEventSubscriber, $tracers);
}
Expand Down
25 changes: 0 additions & 25 deletions src/DependencyInjection/Compiler/TwigInstrumentationPass.php

This file was deleted.

Loading

0 comments on commit cf88e33

Please sign in to comment.