Skip to content

Moved sentry logging to a monolog handler #165

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 20 commits into from
Apr 23, 2025
Merged

Conversation

indykoning
Copy link
Member

Summary

In order to improve update survivability this PR moves the monolog handlers away from a preference and into it's own handler

Result

Functionality wise everything will stay the same, but since we're in a handler now we no longer need to worry about type changes on addRecord

Checklist

  • I've ran composer run codestyle
  • I've ran composer run phpstan

- Logger/Handler/Sentry.php
Copy link
Member Author

Choose a reason for hiding this comment

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

Since we're housing a version for V2 and V3 PHPStan will never be happy

@peterjaap
Copy link
Contributor

When testing this, I'm seeing this error;


There is an error in /data/magento2/vendor/monolog/monolog/src/Monolog/Handler/AbstractHandler.php at line: 58
Monolog\Handler\AbstractHandler::setLevel(): Argument #1 ($level) must be of type Monolog\Level|string|int, null given, called in /data/magento2/vendor/justbetter/magento2-sentry/Logger/Handler/Sentry.php on line 81#0 /data/magento2/vendor/justbetter/magento2-sentry/Logger/Handler/Sentry.php(81): Monolog\Handler\AbstractHandler->setLevel(NULL)

It used to be okay to leave this field empty, but now I have to explicitly declare it in env.php.

@peterjaap
Copy link
Contributor

I'm also running into a circular dependency error: Circular dependency: Magento\Framework\Session\Generic depends on Magento\Customer\Model\Session\Validators\CutoffValidator

And an Area code not set error on the frontend. After disabling the Sentry extension everything works just fine.

@indykoning
Copy link
Member Author

It used to be okay to leave this field empty, but now I have to explicitly declare it in env.php.

This should be fixed now

I'm also running into a circular dependency error: Circular dependency: Magento\Framework\Session\Generic depends on Magento\Customer\Model\Session\Validators\CutoffValidator

And an Area code not set error on the frontend. After disabling the Sentry extension everything works just fine.

Unfortunately i don't see that happening on my side, do you have an extended stack trace on those?
Or perhaps the sentry config you had that caused this?

@indykoning
Copy link
Member Author

I've tested this on Magento 2.4.7 and 2.4.8 and it works for both.

@indykoning indykoning merged commit 420ddf3 into master Apr 23, 2025
2 checks passed
@indykoning indykoning deleted the feature/monolog-handler branch April 23, 2025 11:38
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.

5 participants