Skip to content

Cache tracing causes bug when using TagAwareCacheInterface #524

@WouterCypers

Description

@WouterCypers

Environment

How do you use Sentry?
Sentry SaaS (sentry.io)

Which SDK and version?

sentry.php.symfony at 4.1.3

Steps to Reproduce

  1. Have sentry/sentry-symfony installed at 4.1.3 and make sure to enable cache tracing.
    config/packages/sentry.yaml:
sentry:
    dsn: '%env(SENTRY_DSN)%'
    tracing:
        cache:
            enabled: true
  1. Inject a cache pool TagAwareCacheInterface $integrationsCache into a service and use the RedisTagAwareAdapter:
public function __construct(
    private int $cacheTtl,
    private TagAwareCacheInterface $integrationsCache,
    private NavisionCustomerService $navisionCustomerService,
) {}

config/packages/cache.yaml:

framework:
    cache:
        prefix_seed: my_app
        app: cache.adapter.redis_tag_aware
        default_redis_provider: '%env(resolve:REDIS_DSN)%'
        pools:
            application.cache:
                adapter: cache.adapter.redis_tag_aware
                tags: true
            integrations.cache:
                adapter: cache.adapter.redis_tag_aware
                tags: true
  1. Use the service in an HTTP request.

Expected Result

Symfony should inject an instance RedisTagAwareAdapter into the service.

Actual Result

An exception is thrown:
MyApp\Integrations\Navision\Customer\CachedNavisionCustomerService::__construct(): Argument #2 ($integrationsCache) must be of type Symfony\Contracts\Cache\TagAwareCacheInterface, Symfony\Component\Cache\Adapter\TraceableAdapter given, called in /vagrant/var/cache/dev/ContainerYqNNU93/getCachedNavisionCustomerServiceService.php on line 24

This exclusively happens when Sentry is installed and cache tracing is enabled. I feel this might be an issue in Sentry\SentryBundle\DependencyInjection\Compiler\CacheTracingPass.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions