|
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 | /** |
@@ -212,6 +214,21 @@ private function registerTwigTracingConfiguration(ContainerBuilder $container, a |
212 | 214 | } |
213 | 215 | } |
214 | 216 |
|
| 217 | + /** |
| 218 | + * @param array<string, mixed> $config |
| 219 | + */ |
| 220 | + private function registerCacheTracingConfiguration(ContainerBuilder $container, array $config): void |
| 221 | + { |
| 222 | + $isConfigEnabled = $this->isConfigEnabled($container, $config) |
| 223 | + && $this->isConfigEnabled($container, $config['cache']); |
| 224 | + |
| 225 | + if ($isConfigEnabled && !interface_exists(CacheInterface::class)) { |
| 226 | + throw new LogicException('Cache tracing support cannot be enabled because the symfony/cache Composer package is not installed.'); |
| 227 | + } |
| 228 | + |
| 229 | + $container->setParameter('sentry.tracing.cache.enabled', $isConfigEnabled); |
| 230 | + } |
| 231 | + |
215 | 232 | /** |
216 | 233 | * @param string[] $integrations |
217 | 234 | * @param array<string, mixed> $config |
|
0 commit comments