GithubHelp home page GithubHelp logo

Comments (4)

alcohol avatar alcohol commented on June 6, 2024 1

Ah, did not think of that myself. Cheers, that's an acceptable alternative.

from bugsnag-php.

yousif-bugsnag avatar yousif-bugsnag commented on June 6, 2024

Hi @alcohol, thanks for the suggestion! Can you tell us a little more about why you think this feature would be useful? For example are you getting spammed with large numbers of these log messages?

from bugsnag-php.

alcohol avatar alcohol commented on June 6, 2024

Yeah, unfortunately. My client has a legacy application that needs a lot of patching and fixing, and this noise is making it a bit awkward to spot other issues.

We only discard the following classes in my client's codebase:

- Symfony\Component\HttpKernel\Exception\NotFoundHttpException
- Symfony\Component\Security\Core\Exception\AccessDeniedException
- Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException

But if I peek at the log of the php-fpm service on our servers using journalctl I basically just see a flood of these:

Mar 03 09:49:08 <hostname> php-fpm8.1[1442507]: ool fpm: Discarding event because error class "Symfony\Component\HttpKernel\Exception\NotFoundHttpException" matched discardClasses configuration
Mar 03 09:49:08 <hostname> php-fpm8.1[1442640]: ool fpm: Discarding event because error class "Symfony\Component\HttpKernel\Exception\NotFoundHttpException" matched discardClasses configuration
Mar 03 09:49:38 <hostname> php-fpm8.1[1443398]: ool fpm: Discarding event because error class "Symfony\Component\HttpKernel\Exception\NotFoundHttpException" matched discardClasses configuration
Mar 03 09:49:38 <hostname> php-fpm8.1[1442843]: ool fpm: Discarding event because error class "Symfony\Component\Security\Core\Exception\AccessDeniedException" matched discardClasses configuration
Mar 03 09:49:40 <hostname> php-fpm8.1[1443398]: ool fpm: Discarding event because error class "Symfony\Component\HttpKernel\Exception\NotFoundHttpException" matched discardClasses configuration
Mar 03 09:49:54 <hostname> php-fpm8.1[1443620]: ool fpm: Discarding event because error class "Symfony\Component\HttpKernel\Exception\NotFoundHttpException" matched discardClasses configuration
Mar 03 09:49:54 <hostname> php-fpm8.1[1443398]: ool fpm: Discarding event because error class "Symfony\Component\HttpKernel\Exception\NotFoundHttpException" matched discardClasses configuration
Mar 03 09:49:54 <hostname> php-fpm8.1[1442640]: ool fpm: Discarding event because error class "Symfony\Component\HttpKernel\Exception\NotFoundHttpException" matched discardClasses configuration
Mar 03 09:50:02 <hostname> php-fpm8.1[1442507]: ool fpm: Discarding event because error class "Symfony\Component\HttpKernel\Exception\NotFoundHttpException" matched discardClasses configuration
Mar 03 09:50:03 <hostname> php-fpm8.1[1442843]: ool fpm: Discarding event because error class "Symfony\Component\Security\Core\Exception\AccessDeniedException" matched discardClasses configuration
Mar 03 09:50:03 <hostname> php-fpm8.1[1442640]: ool fpm: Discarding event because error class "Symfony\Component\Security\Core\Exception\AccessDeniedException" matched discardClasses configuration
Mar 03 09:50:04 <hostname> php-fpm8.1[1442507]: ool fpm: Discarding event because error class "Symfony\Component\Security\Core\Exception\AccessDeniedException" matched discardClasses configuration
Mar 03 09:50:04 <hostname> php-fpm8.1[1443620]: ool fpm: Discarding event because error class "Symfony\Component\Security\Core\Exception\AccessDeniedException" matched discardClasses configuration
Mar 03 09:50:04 <hostname> php-fpm8.1[1443398]: ool fpm: Discarding event because error class "Symfony\Component\Security\Core\Exception\AccessDeniedException" matched discardClasses configuration
Mar 03 09:50:04 <hostname> php-fpm8.1[1442843]: ool fpm: Discarding event because error class "Symfony\Component\Security\Core\Exception\AccessDeniedException" matched discardClasses configuration
Mar 03 09:50:04 <hostname> php-fpm8.1[1443620]: ool fpm: Discarding event because error class "Symfony\Component\Security\Core\Exception\AccessDeniedException" matched discardClasses configuration
Mar 03 09:50:04 <hostname> php-fpm8.1[1442508]: ool fpm: Discarding event because error class "Symfony\Component\Security\Core\Exception\AccessDeniedException" matched discardClasses configuration
Mar 03 09:50:08 <hostname> php-fpm8.1[1442650]: ool fpm: Discarding event because error class "Symfony\Component\HttpKernel\Exception\NotFoundHttpException" matched discardClasses configuration
Mar 03 09:50:08 <hostname> php-fpm8.1[1443620]: ool fpm: Discarding event because error class "Symfony\Component\HttpKernel\Exception\NotFoundHttpException" matched discardClasses configuration
Mar 03 09:50:10 <hostname> php-fpm8.1[1442843]: ool fpm: Discarding event because error class "Symfony\Component\Security\Core\Exception\AccessDeniedException" matched discardClasses configuration
Mar 03 09:50:10 <hostname> php-fpm8.1[1442507]: ool fpm: Discarding event because error class "Symfony\Component\Security\Core\Exception\AccessDeniedException" matched discardClasses configuration
Mar 03 09:50:11 <hostname> php-fpm8.1[1443887]: ool fpm: Discarding event because error class "Symfony\Component\Security\Core\Exception\AccessDeniedException" matched discardClasses configuration
Mar 03 09:50:11 <hostname> php-fpm8.1[1442843]: ool fpm: Discarding event because error class "Symfony\Component\Security\Core\Exception\AccessDeniedException" matched discardClasses configuration

from bugsnag-php.

yousif-bugsnag avatar yousif-bugsnag commented on June 6, 2024

Got it, thanks for the additional details. You should be able to achieve that by removing your discardClasses configuration and instead registering your own callback to check for and discard these errors without the syslog call.

The callback gets added to the middleware pipeline and is passed a $report object so you could do something similar to the internal middleware implementation and simply return false from the callback to discard the report:

$errors = $report->getErrors();
foreach ($this->config->getDiscardClasses() as $discardClass) {
foreach ($errors as $error) {
if ($error['errorClass'] === $discardClass
|| @preg_match($discardClass, $error['errorClass']) === 1
) {
syslog(LOG_INFO, sprintf(
'Discarding event because error class "%s" matched discardClasses configuration',
$error['errorClass']
));
return;
}
}
}

from bugsnag-php.

Related Issues (20)

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.