|
35 | 35 | use Symfony\Component\DependencyInjection\Reference; |
36 | 36 | use Symfony\Component\ErrorHandler\Error\FatalError; |
37 | 37 | use Symfony\Component\HttpKernel\DependencyInjection\ConfigurableExtension; |
| 38 | +use Symfony\Contracts\Cache\CacheInterface; |
38 | 39 |
|
39 | 40 | final class SentryExtension extends ConfigurableExtension |
40 | 41 | { |
@@ -68,6 +69,7 @@ protected function loadInternal(array $mergedConfig, ContainerBuilder $container |
68 | 69 | $this->registerTracingConfiguration($container, $mergedConfig['tracing']); |
69 | 70 | $this->registerDbalTracingConfiguration($container, $mergedConfig['tracing']); |
70 | 71 | $this->registerTwigTracingConfiguration($container, $mergedConfig['tracing']); |
| 72 | + $this->registerCacheTracingConfiguration($container, $mergedConfig['tracing']); |
71 | 73 | } |
72 | 74 |
|
73 | 75 | /** |
@@ -214,6 +216,21 @@ private function registerTwigTracingConfiguration(ContainerBuilder $container, a |
214 | 216 | } |
215 | 217 | } |
216 | 218 |
|
| 219 | + /** |
| 220 | + * @param array<string, mixed> $config |
| 221 | + */ |
| 222 | + private function registerCacheTracingConfiguration(ContainerBuilder $container, array $config): void |
| 223 | + { |
| 224 | + $isConfigEnabled = $this->isConfigEnabled($container, $config) |
| 225 | + && $this->isConfigEnabled($container, $config['cache']); |
| 226 | + |
| 227 | + if ($isConfigEnabled && !interface_exists(CacheInterface::class)) { |
| 228 | + throw new LogicException('Cache tracing support cannot be enabled because the symfony/cache Composer package is not installed.'); |
| 229 | + } |
| 230 | + |
| 231 | + $container->setParameter('sentry.tracing.cache.enabled', $isConfigEnabled); |
| 232 | + } |
| 233 | + |
217 | 234 | /** |
218 | 235 | * @param string[] $integrations |
219 | 236 | * @param array<string, mixed> $config |
|
0 commit comments