Skip to content

Update Sentry PSR3 information #1658

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 23, 2025
Merged

Conversation

HypeMC
Copy link
Member

@HypeMC HypeMC commented Aug 12, 2024

Q A
License MIT
Packagist https://packagist.org/packages/sentry/sentry-symfony

There's no need to manually register the PsrLogMessageProcessor, this is done automatically since symfony/monolog-bundle@8f00123 . It's enabled by default, but can be disabled by setting the process_psr_3_messages option to false.

I've also opened a PR in the Sentry docs repo: getsentry/sentry-docs#11063

cc @javiereguiluz

@symfony-recipes-bot symfony-recipes-bot enabled auto-merge (squash) August 12, 2024 22:54
Copy link

github-actions bot commented Aug 12, 2024

Thanks for the PR 😍

How to test these changes in your application

  1. Define the SYMFONY_ENDPOINT environment variable:

    # On Unix-like (BSD, Linux and macOS)
    export SYMFONY_ENDPOINT=https://raw.githubusercontent.com/symfony/recipes-contrib/flex/pull-1658/index.json
    # On Windows
    SET SYMFONY_ENDPOINT=https://raw.githubusercontent.com/symfony/recipes-contrib/flex/pull-1658/index.json
  2. Install the package(s) related to this recipe:

    composer req symfony/flex
    composer req 'sentry/sentry-symfony:^5.0'
  3. Don't forget to unset the SYMFONY_ENDPOINT environment variable when done:

    # On Unix-like (BSD, Linux and macOS)
    unset SYMFONY_ENDPOINT
    # On Windows
    SET SYMFONY_ENDPOINT=

Diff between recipe versions

In order to help with the review stage, I'm in charge of computing the diff between the various versions of patched recipes.
I'm going keep this comment up to date with any updates of the attached patch.

sentry/sentry-symfony

1.0 vs 3.0
diff --git a/sentry/sentry-symfony/1.0/config/packages/prod/sentry.yaml b/sentry/sentry-symfony/3.0/config/packages/prod/sentry.yaml
index 342036fe..5285a224 100644
--- a/sentry/sentry-symfony/1.0/config/packages/prod/sentry.yaml
+++ b/sentry/sentry-symfony/3.0/config/packages/prod/sentry.yaml
@@ -1,2 +1,31 @@
 sentry:
     dsn: '%env(SENTRY_DSN)%'
+    options:
+        excluded_exceptions:
+            - Symfony\Component\HttpKernel\Exception\NotFoundHttpException
+            - Symfony\Component\Security\Core\Exception\AccessDeniedException
+
+#    If you are using Monolog, you also need this additional configuration to log the errors correctly:
+#    https://docs.sentry.io/platforms/php/guides/symfony/#monolog-integration
+#    register_error_listener: false
+
+# monolog:
+#     handlers:
+#         sentry:
+#             type: sentry
+#             level: !php/const Monolog\Logger::ERROR
+#             hub_id: Sentry\State\HubInterface
+
+# If you are using MonologBundle prior to v3.7, you need to configure the handler as a service instead:
+
+# monolog:
+#     handlers:
+#         sentry:
+#             type: service
+#             id: Sentry\Monolog\Handler
+
+# services:
+#     Sentry\Monolog\Handler:
+#         arguments:
+#             $hub: '@Sentry\State\HubInterface'
+#             $level: !php/const Monolog\Logger::ERROR
diff --git a/sentry/sentry-symfony/1.0/config/packages/sentry.yaml b/sentry/sentry-symfony/1.0/config/packages/sentry.yaml
deleted file mode 100644
index e94da2d6..00000000
--- a/sentry/sentry-symfony/1.0/config/packages/sentry.yaml
+++ /dev/null
@@ -1,8 +0,0 @@
-sentry:
-    options:
-        curl_method: async
-
-#    skip_capture:  # To skip certain exceptions, specify a list below
-#      - 'Symfony\Component\HttpKernel\Exception\NotFoundHttpException'
-#      - 'Symfony\Component\HttpKernel\Exception\BadRequestHttpException'
-#      - 'Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException'
diff --git a/sentry/sentry-symfony/1.0/manifest.json b/sentry/sentry-symfony/3.0/manifest.json
index c96ec90e..097e7e84 100644
--- a/sentry/sentry-symfony/1.0/manifest.json
+++ b/sentry/sentry-symfony/3.0/manifest.json
@@ -1,6 +1,6 @@
 {
     "bundles": {
-        "Sentry\\SentryBundle\\SentryBundle": ["all"]
+        "Sentry\\SentryBundle\\SentryBundle": ["prod"]
     },
     "copy-from-recipe": {
         "config/": "%CONFIG_DIR%/"
3.0 vs 4.0
diff --git a/sentry/sentry-symfony/3.0/config/packages/prod/sentry.yaml b/sentry/sentry-symfony/3.0/config/packages/prod/sentry.yaml
deleted file mode 100644
index 5285a224..00000000
--- a/sentry/sentry-symfony/3.0/config/packages/prod/sentry.yaml
+++ /dev/null
@@ -1,31 +0,0 @@
-sentry:
-    dsn: '%env(SENTRY_DSN)%'
-    options:
-        excluded_exceptions:
-            - Symfony\Component\HttpKernel\Exception\NotFoundHttpException
-            - Symfony\Component\Security\Core\Exception\AccessDeniedException
-
-#    If you are using Monolog, you also need this additional configuration to log the errors correctly:
-#    https://docs.sentry.io/platforms/php/guides/symfony/#monolog-integration
-#    register_error_listener: false
-
-# monolog:
-#     handlers:
-#         sentry:
-#             type: sentry
-#             level: !php/const Monolog\Logger::ERROR
-#             hub_id: Sentry\State\HubInterface
-
-# If you are using MonologBundle prior to v3.7, you need to configure the handler as a service instead:
-
-# monolog:
-#     handlers:
-#         sentry:
-#             type: service
-#             id: Sentry\Monolog\Handler
-
-# services:
-#     Sentry\Monolog\Handler:
-#         arguments:
-#             $hub: '@Sentry\State\HubInterface'
-#             $level: !php/const Monolog\Logger::ERROR
diff --git a/sentry/sentry-symfony/4.0/config/packages/sentry.yaml b/sentry/sentry-symfony/4.0/config/packages/sentry.yaml
new file mode 100644
index 00000000..48635325
--- /dev/null
+++ b/sentry/sentry-symfony/4.0/config/packages/sentry.yaml
@@ -0,0 +1,29 @@
+when@prod:
+    sentry:
+        dsn: '%env(SENTRY_DSN)%'
+
+#        If you are using Monolog, you also need this additional configuration to log the errors correctly:
+#        https://docs.sentry.io/platforms/php/guides/symfony/#monolog-integration
+#        register_error_listener: false
+
+#    monolog:
+#        handlers:
+#            sentry:
+#                type: sentry
+#                level: !php/const Monolog\Logger::ERROR
+#                hub_id: Sentry\State\HubInterface
+
+#    If you are using MonologBundle prior to v3.7, you need to configure the handler as a service instead:
+
+#    monolog:
+#        handlers:
+#            sentry:
+#                type: service
+#                id: Sentry\Monolog\Handler
+
+#    services:
+#        Sentry\Monolog\Handler:
+#            arguments:
+#                $hub: '@Sentry\State\HubInterface'
+#                $level: !php/const Monolog\Logger::ERROR
+#                $bubble: false
diff --git a/sentry/sentry-symfony/3.0/manifest.json b/sentry/sentry-symfony/4.0/manifest.json
index 097e7e84..9e07f9cc 100644
--- a/sentry/sentry-symfony/3.0/manifest.json
+++ b/sentry/sentry-symfony/4.0/manifest.json
@@ -7,5 +7,8 @@
     },
     "env": {
         "SENTRY_DSN": ""
+    },
+    "conflict": {
+        "symfony/framework-bundle": "<5.4"
     }
 }
4.0 vs 4.6
diff --git a/sentry/sentry-symfony/4.0/config/packages/sentry.yaml b/sentry/sentry-symfony/4.6/config/packages/sentry.yaml
index 48635325..9e88fbc5 100644
--- a/sentry/sentry-symfony/4.0/config/packages/sentry.yaml
+++ b/sentry/sentry-symfony/4.6/config/packages/sentry.yaml
@@ -1,10 +1,16 @@
 when@prod:
     sentry:
         dsn: '%env(SENTRY_DSN)%'
+        # this hooks into critical paths of the framework (and vendors) to perform
+        # automatic instrumentation (there might be some performance penalty)
+        # https://docs.sentry.io/platforms/php/guides/symfony/performance/instrumentation/automatic-instrumentation/
+        tracing:
+            enabled: false
 
 #        If you are using Monolog, you also need this additional configuration to log the errors correctly:
 #        https://docs.sentry.io/platforms/php/guides/symfony/#monolog-integration
 #        register_error_listener: false
+#        register_error_handler: false
 
 #    monolog:
 #        handlers:
@@ -12,18 +18,5 @@ when@prod:
 #                type: sentry
 #                level: !php/const Monolog\Logger::ERROR
 #                hub_id: Sentry\State\HubInterface
-
-#    If you are using MonologBundle prior to v3.7, you need to configure the handler as a service instead:
-
-#    monolog:
-#        handlers:
-#            sentry:
-#                type: service
-#                id: Sentry\Monolog\Handler
-
-#    services:
-#        Sentry\Monolog\Handler:
-#            arguments:
-#                $hub: '@Sentry\State\HubInterface'
-#                $level: !php/const Monolog\Logger::ERROR
-#                $bubble: false
+#                fill_extra_context: true # Enables sending monolog context to Sentry
+#                process_psr_3_messages: false # Disables the resolution of PSR-3 placeholders
diff --git a/sentry/sentry-symfony/4.0/manifest.json b/sentry/sentry-symfony/4.6/manifest.json
index 9e07f9cc..9922cfe2 100644
--- a/sentry/sentry-symfony/4.0/manifest.json
+++ b/sentry/sentry-symfony/4.6/manifest.json
@@ -9,6 +9,7 @@
         "SENTRY_DSN": ""
     },
     "conflict": {
-        "symfony/framework-bundle": "<5.4"
+        "symfony/framework-bundle": "<5.4",
+        "symfony/monolog-bundle": "<3.7"
     }
 }
4.6 vs 5.0
diff --git a/sentry/sentry-symfony/4.6/config/packages/sentry.yaml b/sentry/sentry-symfony/5.0/config/packages/sentry.yaml
index 9e88fbc5..82ecf958 100644
--- a/sentry/sentry-symfony/4.6/config/packages/sentry.yaml
+++ b/sentry/sentry-symfony/5.0/config/packages/sentry.yaml
@@ -1,11 +1,13 @@
 when@prod:
     sentry:
         dsn: '%env(SENTRY_DSN)%'
-        # this hooks into critical paths of the framework (and vendors) to perform
-        # automatic instrumentation (there might be some performance penalty)
-        # https://docs.sentry.io/platforms/php/guides/symfony/performance/instrumentation/automatic-instrumentation/
-        tracing:
-            enabled: false
+        # Add request headers, cookies, IP address and the authenticated user
+        # see https://docs.sentry.io/platforms/php/data-management/data-collected/ for more info
+        # send_default_pii: true
+        options:
+            ignore_exceptions:
+                - 'Symfony\Component\ErrorHandler\Error\FatalError'
+                - 'Symfony\Component\Debug\Exception\FatalErrorException'
 
 #        If you are using Monolog, you also need this additional configuration to log the errors correctly:
 #        https://docs.sentry.io/platforms/php/guides/symfony/#monolog-integration

@HypeMC
Copy link
Member Author

HypeMC commented Oct 29, 2024

The PR on the Sentry docs repo has now been merged.

@diimpp
Copy link
Member

diimpp commented Apr 19, 2025

Hi @cleptric, could you please take a look if it makes sense to make this change to recipes?

Copy link
Contributor

@cleptric cleptric left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would add this, else lgtm.

@symfony-recipes-bot symfony-recipes-bot merged commit 06fdc1b into symfony:main Apr 23, 2025
2 checks passed
@HypeMC HypeMC deleted the sentry-psr3 branch April 23, 2025 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants