Skip to content

Sentry and Symfony error handlers conflicts #609

Closed
@alexander-schranz

Description

@alexander-schranz

Environment

How do you use Sentry?
self-hosted/on-premise

sentry/sdk                                 3.1.1 
sentry/sentry                              3.4.0      
sentry/sentry-symfony                      4.2.7 

Steps to Reproduce

Have a symfony project with deprecations:

Run console command which triggers deprecation e.g.:

bin/console cache:clear

Output is normally:

Bildschirmfoto 2022-03-31 um 12 33 41

Install sentry / sentry bundle run again:

bin/console cache:clear

Bildschirmfoto 2022-03-31 um 12 33 22

It looks for me there is some conflicts between symfony error handler (think it handles also deprecations) and the sentry error handler.

In our case we already had disabled the error_listener but it does not have any effects depending on sentry symfony monolog integration:

config/packages/sentry.yaml
sentry:
    dsn: "%env(SENTRY_DSN)%"
    register_error_listener: false # Disable ErrorListener to avoid duplicated events because of monolog handler
    options:
        attach_stacktrace: true # Attach stacktrace to monolog events that do not include an exception
        send_default_pii: true # Include personally identifiable information like user, cookies and headers
        integrations:
            - 'Sentry\Integration\IgnoreErrorsIntegration'

# monolog configuration for sentry
# see also: https://docs.sentry.io/platforms/php/guides/symfony/
monolog:
    handlers:
        sentry:
            type: sentry
            level: !php/const Monolog\Logger::ERROR
            hub_id: Sentry\State\HubInterface

services:
    Monolog\Processor\PsrLogMessageProcessor:
        tags: { name: monolog.processor, handler: sentry }

    Sentry\Integration\IgnoreErrorsIntegration:
        arguments:
            $options:
                ignore_exceptions:
                    - 'Symfony\Component\HttpKernel\Exception\NotFoundHttpException'

This issue is maybe related to: #337 and maybe a register_error_handler: false suggested by @Jean85 could fix this issue. But I'm not sure 100% sure it seems to appear only since symfony 5.4/6.0 release and the other issue seems to be older.

Expected Result

Do not output the deprecation notices.

Actual Result

Outputs the deprecation notices.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions