Skip to content

Commit

Permalink
Fix the auto-detection of the Cache component to enable performance…
Browse files Browse the repository at this point in the history
… tracing (#501)
  • Loading branch information
guillaume-ro-fr authored May 12, 2021
1 parent 1a4080a commit 9e101ad
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- Fix the CacheItem detection for tracing (#501)

## 4.1.1 (2021-05-10)

- Fix the conditions to automatically enable the cache instrumentation when possible (#487)
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ private function addDistributedTracingSection(ArrayNodeDefinition $rootNode): vo
->{class_exists(TwigBundle::class) ? 'canBeDisabled' : 'canBeEnabled'}()
->end()
->arrayNode('cache')
->{interface_exists(CacheItem::class) ? 'canBeDisabled' : 'canBeEnabled'}()
->{class_exists(CacheItem::class) ? 'canBeDisabled' : 'canBeEnabled'}()
->end()
->end()
->end()
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/SentryExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ private function registerCacheTracingConfiguration(ContainerBuilder $container,
$isConfigEnabled = $this->isConfigEnabled($container, $config)
&& $this->isConfigEnabled($container, $config['cache']);

if ($isConfigEnabled && !interface_exists(CacheItem::class)) {
if ($isConfigEnabled && !class_exists(CacheItem::class)) {
throw new LogicException('Cache tracing support cannot be enabled because the symfony/cache Composer package is not installed.');
}

Expand Down
2 changes: 1 addition & 1 deletion tests/DependencyInjection/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function testProcessConfigurationWithDefaultConfiguration(): void
'enabled' => class_exists(TwigBundle::class),
],
'cache' => [
'enabled' => interface_exists(CacheItem::class),
'enabled' => class_exists(CacheItem::class),
],
],
];
Expand Down

0 comments on commit 9e101ad

Please sign in to comment.