-
Notifications
You must be signed in to change notification settings - Fork 173
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
Change default hook system to use Monolog #337
Comments
@B-Galati would you like to help here? Due to your work on https://github.com/B-Galati/monolog-sentry-handler, you're probably an expert on this approach... |
Hello! This is exactly the reason why I never used this bundle is my own applications before, I'm really glad it's now on the table :) ! I'm posting a comment because I implemented this in most my projects and it may be useful to share it. I think Benoit may even have worked with my implementation on En Marche :) . I created an open-source project with this implementation, which I didn't share much yet as it's not generic and well-tested enough: https://gitlab.com/citepolitique/oss/sentry. There are 2 main files in my implementation:
Both are used in Monolog configuration: sentry:
dsn: '%env(SENTRY_DSN)%'
monolog:
handlers:
main:
type: fingers_crossed
action_level: error
activation_strategy: 'citepolitique.sentry.activation_strategy'
handler: nested
nested:
type: group
members: [file, buffer]
file:
type: stream
path: '%kernel.logs_dir%/%kernel.environment%.log'
level: debug
buffer:
type: buffer
handler: sentry
sentry:
type: service
id: 'citepolitique.sentry.monolog_handler' This example of configuration is great to see why using Monolog is so powerful: in a few lines of configuration, I added an activation strategy to ignore 403/404, created debug log file, created a debug buffer in memory and sent exception to Sentry with the debug context from the buffer if there is a problem. I can update this behavior easily and chain other handlers if I want to easily. |
Thanks for the input @tgalopin! Do you think that that approach is feasible in this bundle? It doesn't seems so to me, but I'm unclear on some inner workings of the Monolog bundle, so I'm probably wrong; more input are more than welcome! |
I'm not sure why it wouldn't be feasible, I just did it in a bundle myself :) . Are there specific reasons blocking you to do it here? I feel like a boolean option such as |
But you had to write the Monolog config by yourself, right? What I was expecting to do is:
How to do that seems a bit foggy to me, since it seems that even @B-Galati did not take this route... Can I just call
That's the easiest part, there's already a |
Hello and thanks for pinging me, I am super happy about this issue :-) I would be happy to help on any subject so feel free to ping me for code review, issues, submitting a PR or helping on a PR. I explained my approach in this doc: https://github.com/B-Galati/monolog-sentry-handler/blob/master/doc/guide-symfony.md. Basically, I did not try yet, but this bundle could already proposed monolog as the default hook system. It would require a doc update and a recipe update. I deeply think that this bundle could be simplified a lot by being a bit more opinionated. I had a positive feedback here B-Galati/monolog-sentry-handler#19. (ping @temp, you may be interested by this issue). So for the next major of this bundle I would see :
|
Sure! I'm more than happy to receive help on this. Once we settle on how to proceed, I would say that you can send as many PRs as you want!
And be released as a new major, or users could bump into unwanted behavior after a silly Also: would the recipe be enough to hook into Monolog?
The drawback that I see is the absence of Monolog, or wanting to use Monolog for different purposes; anyhow, since #322 is already ready to merge, I woud just merge it and leave it as a fallback method, basically reverting the current bundle behavior (which has Monolog optional)
Sure! Also, that could be handled at the transport level, with i.e. spooling.
I would add into this bundle to not tie ourselves to the SDK releases. It would be always possible to port it upstream later.
What do you mean with this?
That's something baked inside the base SDK. To do that, we would have to inject it in the |
Thanks @temp!
I don't think so, people would need to copy/paste a config example manually. It was the the problem with easy_log for example (https://github.com/symfony/recipes/blob/ce83283b198ddafcb9e0a053d34441723fdb9e3f/easycorp/easy-log-handler/1.0/config/packages/dev/easy_log_handler.yaml)
I meant having a simple factory class that can handle all cases instead of doing everything within the extension / compiler passes / etc. That's easier to test and maintain. But well that's not the point of this issue, sorry. @Jean85 Let me know how you would like to move forward ;-) |
@B-Galati I've merged #337 and committed 02e6902, so now master is 4.x only.
Do you think I'm missing something? I'll create a branch for 3.x (I have to fix #345) to continue there. |
LGTM ;-) Would you like to use my lib as monolog handler or you prefer something built-in the bundle or the SDK? |
Probably having it built-in would make it easier to maintain, but feel free to attribute your work if you want to port it inside! |
Alright, IMHO better to have it in the SDK. What do you prefer? |
Do you mean committing it into the |
Reporting an overlooked issue from #363 (comment):
This regards the Messenger specifically, but I fear that the same issue would arise elsewhere... @B-Galati did you encounter such issues? How did you handle those? |
I am doing something similar as what's currently in the bundle: https://github.com/getsentry/sentry-symfony/blob/c0d0ca35e825b96d1b4976901b2b8f373c30a99f/src/EventListener/MessengerListener.php. But with a PSR logger. I did not implement a It's documented here: https://github.com/B-Galati/monolog-sentry-handler/blob/master/doc/guide-symfony.md#step-4-flush-monolog-on-each-handled-symfony-messenger-message. The trick is to call I am not sure it would be possible to implement the |
It looks like it would be possible with a |
I understand that sometime it's better without But in my case I'm calling an API which failing about half the time. If I get a message on Sentry for every soft fail, I will miss the hard fail. |
I've just had a possible idea on how to roll out this feature without a major version bump. Let me explain:
@ste93cry WDYT? |
Pinning #286, should be interesting to this feature. |
This issue has gone three weeks without activity. In another week, I will close it. But! If you comment or otherwise update it, I will reset the clock, and if you label it "A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀 |
@Jean85 what is the latest on this? Is there anyway I can help? |
I'm sorry but, apart from not having any idea on how to proceed with this, I don't have time to spend to investigate. @cleptric what we want to do? I still think this should be the way to go, but I can't find a way to hook into Monolog automatically. |
Nicolas, a Symfony Core member, suggested to change approach on how to attach Sentry to Symfony.
This requires a new major version since it's a big, impactful change, and still requires #322 as a fallback mechanism.
The text was updated successfully, but these errors were encountered: