Giter Site home page Giter Site logo

getsentry / sentry-symfony Goto Github PK

View Code? Open in Web Editor NEW
679.0 56.0 168.0 1.38 MB

The official Symfony SDK for Sentry (sentry.io)

Home Page: https://sentry.io

License: MIT License

PHP 99.89% Shell 0.11%
php symfony symfony-bundle sentry bundle sentry-client hacktoberfest tag-production

sentry-symfony's People

Contributors

addvilz avatar agentsib avatar alexander-schranz avatar bafor avatar bouland avatar cklm avatar cleptric avatar dcramer avatar dependabot[bot] avatar garak avatar getsentry-bot avatar guilliamxavier avatar hazat avatar hypemc avatar jean85 avatar localheinz avatar matthew-gill avatar michaelzangerle avatar nocive avatar rdohms avatar rjd22 avatar ruudk avatar server-may-cry avatar simpod avatar stayallive avatar ste93cry avatar swquinn avatar thomas-medelse avatar vladyslavstartsev avatar yozhef avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sentry-symfony's Issues

ExceptionListener does not catch every exception

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.

Exception are grouped the wrong way due to wrong stacktrace

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.

Screenshot
sentry-screenshot

Sentry not working on specific domain

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

Missing use statement

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

server_name tag has initialized at build server

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.

Generate release and tag

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.

Some tests?

Should we have some tests in this bundle, to verify the functionality? :)

  • PHPUnit
  • PHPSpec

Could write some. Would certainly make me sleep better.

POST data not recorded

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?

Create new tagged release

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.

Disable sentry for tests

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?

Handler Shutdown Error in Console Command

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.

Added a Monolog handler

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.

Symfony error pages are not being show correctly

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:

Bad:
bad

Good:
good

And when I'm in 'prod' environment, my customized error page is also not shown, as stated in the following images:

Bad:
bad2

Good:
good2

Class 'Sentry' not found

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

Pass the exception class as parameter.

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%

Console Exceptions being logged twice

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

The annotation "@doc" in method Raven_Client::parseDSN() was never imported

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 ?

[0.2] Fatal error: Call to undefined method Raven_Client::setRelease()

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);

Error Handler not registered for CLI Commands

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:

  • Add a listener to an event that is always thrown that forces instantiation of the client.
  • Add this same command to the current listener
  • Find another way to hook into kickoff procedure to ensure the client is always instantiated, like doing this in the Extension for example.

I'm going to explore a few to see if I can find the best way.

Add Symfony related GitHub topics

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.

Set Current User

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?

REMEMBERME cookie sent to Sentry

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

Support for symfony 2.3 was dropped on version 0.3.0 even though symfony 2.3 is still maintained until may 2017.

No proper error page in case of fatal error when this bundle is activated

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:

error 500

My env is:
PHP 7.1
Symfony v3.3.10
sentry/sentry-symfony 0.8.6

Configuration value from new options structure is overridden by deprecated options

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:

- [setEnvironment, ['%sentry.environment%']]

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);

Set Release Version

I do not see a way to easily set the release version using this new bundle. Am I overlooking something?

Listener priority on kernel.exception

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 ?

Timestamp not getting processed

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"
}

Options config value accepts only scalar values

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

Exceptions when spooling emails not logged

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.

Unable to report error manually

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?

Ignore ErrorException thrown by Symfony

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.

Suppressed errors will still bubbling up

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?

Release 2.0 and support for Symfony 4

As explained in #86 (comment), I want to create immediately a 2.0 release after the 1.0. This release will:

  • drop support for Symfony 2.x
  • support Symfony 4.x
  • require PHP 7.1+
  • thus, will leverage all the new language features (return, scalar and nullable types to start with)

Release new version

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"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.