getsentry / sentry-symfony Goto Github PK
View Code? Open in Web Editor NEWThe official Symfony SDK for Sentry (sentry.io)
Home Page: https://sentry.io
License: MIT License
The official Symfony SDK for Sentry (sentry.io)
Home Page: https://sentry.io
License: MIT License
ExceptionListener does not catch below exception:
[2017-07-07 10:06:56] request.CRITICAL: Uncaught PHP Exception ReflectionException: "Class FooBundle/BarClass does not exist" at /var/www/symfony/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/RuntimeReflectionService.php line 72 {"exception":"[object] (ReflectionException(code: -1): Class FooBundle\\BarClass does not exist at /var/www/symfony/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/RuntimeReflectionService.php:72)"} []
because for this case kernel.exception
is not generated.
There is an option for that --
.We are using 0.5 and sentry/sentry 1.5.0 in production, and we are currently seeing a strange behavior in Sentry: it's grouping together exceptions that came from very different places, just because they are the same classes (\LogicException
).
I thing the culprit is the stacktrace.
Due to how Symfony is build, there is a $response = call_user_func_array($controller, $arguments);
in every handled request. If do not ask to see the full stacktrace, Sentry shows only it up to that line, hiding al the code that belong to my project; I think this leads to the wrong grouping.
Hi,
I have two different servers running the same Symfony application, one is my developement/testing server, the second is the production server.
I installed sentry using the bundle following the instructions given in the documentation, but i'm only receiving errors from the test server, no errors seems to be sent from the production server.
Months ago, sentry worked fine on the two domains, and we didn't change anything.
I tried to install Sentry via monolog too, but the problem persists : we only get errors from the testing server.
Does anyone have an idea what could be wrong ?
Thanks
ExceptionListener
is missing a use statement.
PHP Fatal error: Class 'Sentry\SentryBundle\EventListener\SentrySymfonyClient' not found in /.../vendor/sentry/sentry-symfony/src/Sentry/SentryBundle/EventListener/ExceptionListener.php on line 46
Hello! I have faced an issue that all Sentry issues contain the same server_name tag.
I build an application once time on a CI server, then deploy already cache-warmed app to production stage.
I see all Sentry issues contain my CI server name instead of production server name, where an error had been occured.
I use sentry-symfony 1.0.1 and sentry 1.8.2 in my dependencies.
Sentry still using console.exception event and it's deprecated since Symfony 3.3 Use console.error event instead.
This is a problem when running PHPUnit tests which runs console commands.
The current version (0.2.1) has a huge bug on the ExceptionListener - It's importing the HttpExceptionInterface instead of HttpException.
Please generate a new release.
Should we have some tests in this bundle, to verify the functionality? :)
Could write some. Would certainly make me sleep better.
In our tests we have noticed that the POST data is not sent along for reproducing bugs.
Is there a way to gather more data and send it along by default, or is it a matter of extending the bundle classes and rolling out your own?
Would it be possible to get a new release out of the door?
52 commits to master since this release
The bundle doesn't work out of the box with Symfony Flex because it wants to get a tagged release with the Symfony Flex fixes.
I've got the following problem:
When I run PHPUnit on my symfony application it always exits at the same test without any exception or hint. When I run PHPUnit just for this one test where it stops everything works fine, but I get the following message:
THE ERROR HANDLER HAS CHANGED!
When I disable sentry completely then everything works fine and at the end I get some deprecation warnings. When I remove those deprecations and enable sentry again everything works.
So it seems that it exits when it finds some deprecated calls.
So my question is, how can I disable sentry for the tests or is there another way to fix this issue?
I have a long running Symfony Console command that starts a Process (Also from Symfony) on a regular interval.
Now in case there is an unexpected error I had a Shutdown Function registered before using sentry.
After some testing, it seems that sentry did not send those errors with just registering the bundle and config.
So i've added these in the execute method:
$errorHandler = new \Raven_ErrorHandler($this->getContainer()->get('sentry.client'));
$errorHandler->registerErrorHandler();
$errorHandler->registerShutdownFunction();
And now it works.
Weirdly, some time after the errors did seem to come in. (like 30 min)
So my question would be: Do I need to add this Raven_ErrorHandler and call those two methods. Or is this done automaticaly ?
I was cruising around the EventListener in this repo but did not find anything alike.
Hello,
Logging Symfony error is great.
Adding a Monolog handler in this bundle would be great: in our application, we are using Monolog to log business errors all around, we would like to have those sent to Sentry as well.
Having a config parameter to activate that would be great, as a little bit of bootstrapping code is required.
In many cases, we should not send the error on development node.
Maybe add the parameter for control enable or disable listen to the exception?
sentry:
enable: "!%kernel.debug%"
After I enable sentry, when a error 500 happens, the error page is not shown correctly. When I'm in 'dev' environment, the symfony debug page is not shown, as stated in the following images:
And when I'm in 'prod' environment, my customized error page is also not shown, as stated in the following images:
Hello,
Just followed the readme with composer require sentry/sentry
before.
The bundle line is underlined in PhpStorm because it doesn't know where to find new Sentry/SentryBundle/SentryBundle()
.
Is there something missing? Autoloader?
Bests
https://docs.sentry.io/clients/php/usage/#handling-failures - it would be good to know when and why event was not reported to Sentry
Now, the validation of exception class (instanceof) exist in configuration layer and after this I cannot set the class of listener as parameter: %parameter_name%
Maybe better remove this validation or move to compiler pass or extension, where we can resolve the value?
sentry:
exception_listener: %my_app.sentry_exception_listener.class%
Hello, this month my team received a notice that our logging limit was exceeded, and investigating it we found out some errors were being sent to sentry twice.
After a fast test it seems that the Sentry ExceptionListener is listening to both ConsoleErrorEvent
and ConsoleExceptionEvent
, that are dispatched by Symfony\Component\Console\Application
for a single exception that occurs.
sentry-symfony: 2.0
sentry: 1.8.2
symfony: 3.4.4
Using
PHP 7.1
Symfony 2.8.24
sentry/sentry-symfony 0.8.0
doctrine bundle 1.6.8
doctrine orm v2.5.6
when clearing the cache of the application, or trying to simply app/console
, we get:
Uncaught Doctrine\Common\Annotations\AnnotationException: [Semantical Error] The annotation "@doc" in method Raven_Client::parseDSN() was never imported. Did you maybe forget to add a "use" statement for this annotation? in /srv/app/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationException.php:54
Stack trace:
#0 /srv/app/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocParser.php(727): Doctrine\Common\Annotations\AnnotationException::semanticalError('The annotation ...')
#1 /srv/app/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocParser.php(663): Doctrine\Common\Annotations\DocParser->Annotation()
#2 /srv/app/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocParser.php(354): Doctrine\Common\Annotations\DocParser->Annotations()
#3 /srv/app/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationReader.php(282): Doctrine\Common\Annotations\DocParser->parse('/**\n * Pars...', 'method Raven_Cl...')
#4 /srv/app/vendor/doctrine/annota in /srv/app/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationException.php on line 54
Clearing the cache manually, restarting php-fpm, re-installing vendors from scratch does not solve the problem.
Do you have an idea on what's causing Doctrine to try to parse the @doc
?
I just upgraded to 0.2, and it goes on this error. #5 seems to be responsible, in which @dcramer said that a patch release of sentry was needed... Maybe this bit was missing?
Raw stack trace:
Symfony\Component\Debug\Exception\FatalThrowableError: Fatal error: Call to undefined method Raven_Client::setRelease()
Module "app.php", line 28
$response = $kernel->handle($request);
Module "bootstrap.php.cache:Symfony\Component\HttpKernel\Kernel", line 2306, in handle
return $this->getHttpKernel()->handle($request, $type, $catch);
Module "bootstrap.php.cache:Symfony\Component\HttpKernel\HttpKernel", line 2961, in handle
return $this->handleException($e, $request, $type);
Module "bootstrap.php.cache:Symfony\Component\HttpKernel\HttpKernel", line 3025, in handleException
$this->dispatcher->dispatch(KernelEvents::EXCEPTION, $event);
Module "EventDispatcher.php:Symfony\Component\EventDispatcher\EventDispatcher", line 42, in dispatch
if ($listeners = $this->getListeners($eventName)) {
Module "ContainerAwareEventDispatcher.php:Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher", line 127, in getListeners
$this->lazyLoad($eventName);
Module "ContainerAwareEventDispatcher.php:Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher", line 181, in lazyLoad
$listener = $this->container->get($serviceId);
Module "bootstrap.php.cache:Symfony\Component\DependencyInjection\Container", line 2107, in get
$service = $this->$method();
Module "appProdProjectContainer.php:appProdProjectContainer", line 3609, in getSentry_ExceptionListenerService
return $this->services['sentry.exception_listener'] = new \Sentry\SentryBundle\EventListener\ExceptionListener($this->get('sentry.client'));
Module "bootstrap.php.cache:Symfony\Component\DependencyInjection\Container", line 2107, in get
$service = $this->$method();
Module "appProdProjectContainer.php:appProdProjectContainer", line 3591, in getSentry_ClientService
$instance->setRelease(NULL);
Hi, it is necessary to handle console command errors.
Registration of the Client happens when the Client::install
command is called by the container as it instantiates the Service.
In the scenario of a web request, this is done by the Kernel as it always triggers the kernel.request
which causes it to load the listener and thus boot the client which then hooks into the PHP Erro Handler and registers itself.
However in the context for a CLI Command, there is no Kernel. And the listener only listens to console.exception
. Since Symfony lazy-ly only instantiates the listeners if the event happens, when no exception is thrown the listener will never be instantiated, thus the client won't either and will never hook itself into the PHP Error Handler, and thus PHP Notices
for example, will go by unchecked and never reported to Sentry.
Solutions:
I'm going to explore a few to see if I can find the best way.
Now that Github introduced the topics feature for all repositories, Symfony proposed in this blog post to standardize some tags for all Symfony related repositories to make easier to discover them. The official recommendation is to add php, symfony, bundle and symfony-bundle topics and then, your own specific topics.
In the old monolog raven way, there was a way to create a custom processor that allows you to set the current logged in user and any associated data keys.
How could this be accomplished now?
Hey,
Currently the cookie used to store a "remember-me" token is sent to Sentry. Knowing this value lets an adversary impersonate a user. Perhaps this should be sent as filtered out-of-the-box just like PHPSESSID
is filtered.
Note that simply filtering the default REMEMBERME
cookie does not cut it. The name can be configured (http://symfony.com/doc/current/security/remember_me.html). Best option IMO is to use a compiler pass and grab it from a certain service definition argument. In the compiler pass we would have to figure the "remember-me" service id (it's dynamic I think), find the service and then infer the cookie name from the 3-rd "options" argument. The relevant part in Symfony can be found here.
Cheers,
Kristen
Support for symfony 2.3 was dropped on version 0.3.0 even though symfony 2.3 is still maintained until may 2017.
Hi!
I'm having a small problem with this bundle:
When I activate it, Symfony doesn't handle PHP fatal errors anymore.
Let's say I have a $this->nonExistingMethod();
in one of my controller. Without this bundle, in prod env, Symfony displays a "pretty" HTML error page.
With this bundle, I get this instead:
My env is:
PHP 7.1
Symfony v3.3.10
sentry/sentry-symfony 0.8.6
https://travis-ci.org/getsentry/sentry-symfony/jobs/157938242 fails in HHVM when getting mock of the internal exception.
I'll see to this as soon as I get a minute or two.
I'm trying to use a new options structure to set up the environment name (sentry.options.environment
) and it seems it doesn't work properly. The structure I've got looks like that:
sentry:
dsn: http://xxxxxx
options:
environment: staging
Unfortunately all errors I receive in sentry are tagged with the environment name of "prod" which seems to be the default value for the symfony application (running through web/app.php
front controller). I was wondering if sentry bundle still defaults to the deprecated option (sentry.environment
). I think I found the issue here:
It seems the client object is constructed with options from the sentry.options
and then some of options are overridden by deprecated values (for example sentry.environment
);
I do not see a way to easily set the release version using this new bundle. Am I overlooking something?
Hi,
Today, i get the exception on sentry even if I catch it from kernel.exception and want to redirect my user instead of seeing it on sentry.
Can the listener have lower priority on kernel.exception event ?
What do you think ?
Hi,
Currently, there's no option to disable the bundle
So our local tests and our Travis builds are sending exception to Sentry that are useless
Why not provide a configuration option like http://symfony.com/doc/current/components/config/definition.html#optional-sections ?
Would be nice to have way set wich exception classes not store here
HttpExceptionInterface is not enought
Right now I'm getting this strange behavior in our Sentry setup:
There was 1 error encountered while processing this event
Discarded invalid value for parameter 'timestamp'{ "name": "timestamp", "value": "2016-11-24T09:15:35Z" }
I was trying to set the options
config key in the Symfony configuration but it accepts only scalar values while it should accept an array of key/values. Changing the prototype
of the node from scalar
to variable
in the config tree builder works, although I think it would be better to have a full definition that checks all options available so that a user cannot add whatever he wants. Let me know what you think about this, I could submit a PR that fixes the issue
In sentry i dont see a full stack trace cause of bootstrap.php.cache, is there a configuration i am missing?
When I enable the Sentry bundle I get the browser's default error page when an exception happens and not the Symfony dev environment error page.
From what I can tell simply listening for the kernel.request event causes this issue...
I am using Symfony 2.7, if that is useful to you.
Currently sentry stores only command name as tags. Should you also store command params for later debugging?
If using a memory spool for Swiftmailer and something goes wrong during the email sending, no exception is logged in Sentry.
It would be really nice if this could be logged. Email debugging is hard enough as it is.
The exception is only logged in \Symfony\Bundle\SwiftmailerBundle\EventListener\EmailSenderListener::onTerminate
.
Hi!
Nice and clear bundle, thank you for your work!
I have problem/proposition: user should be able to report exception manually:
<?php
try {
return doSmth();
} catch (Exception $e) {
$error_reporter->processException($e);
return 'default';
}
I think we should have a service that can report exceptions, sets user data etc. And such service we should use inside event listeners for DRY reasons.
What do you think @Jean85?
Hi,
Please could you give me how to properly disable sentry on dev environment ?
What is the best practice ?
thanks
Can you guys fix it? :)
After catching errors (like TypeError
) Symfony is also throwing ErrorException
and that results in two exceptions being reported to Sentry instead of reporting only the first one.
The simplest solution would be adding ErrorException
to list of ignored exceptions, but i am not sure if that's a good idea.
I have a lot of "file not found" errors in sentry because of this line in PhpFileCache.php from the Doctrine package:
// note: error suppression is still faster than `file_exists`, `is_file` and `is_readable`
$value = @include $fileName;
The @ will suppress the error, but sentry still log it. Is there a way to ignore these?
As explained in #86 (comment), I want to create immediately a 2.0 release after the 1.0. This release will:
I would like to use the skip capture option with the stable version of the library, is it possible to release a new stable version with this option in the release?
With the version 0.3.0 I get an error message: Unrecognized option "skip_capture" under "sentry"
On https://docs.getsentry.com/hosted/clients/php/integrations/symfony2/ It states to add:
new Sentry/SentryBundle/SentryBundle(),
However it should be:
new Sentry\SentryBundle\SentryBundle(),
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.