-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
How can we add monolog context to Sentry #4125
Comments
@stayallive is this something you can help with? |
Routing to @getsentry/team-webplatform for triage. ⏲️ |
The point is that by default (and by design as said in ) we do not copy context from Monolog in the base SDK. So we need a basic example for the PHP SDK first, and the we can add on top how to fit that in a Symfony app. I don't recall exactly what you need to do for the first step, but ping me for the second one. |
@Jean85 you mean just like this: https://docs.sentry.io/platforms/php/enriching-events/context/ or referring to Monolog specifically or are they the same? |
Yes I meant specific code related to Monolog. Ok I've dug a bit here and there, and here's what I've found:
So... Seeing such high demand, IMHO we could revisit this issue and add the implementation in the SDK, but NOT use it by default. At a first glance, your Laravel seems framework agnostic, so we could simply port it in the base SDK (along with tests) and make it optional; at that point, it would be straightforward to make it a configuration option in the Symfony bundle too. WDYT @ste93cry? |
We do the same, the
I'm not strongly opposed to this, but I also think that we had good reasons in the past to deny implementing this out-of-the-box. Moreover, it was @untitaker the first one to suggest that there were similar issues in the Python SDK that led to the decision of not going forward with such feature request. From what I saw in the past, the problem is mainly lack of knowledge about how to implement this on your own (well, it's actually quite simple so I'm not sure what's the issue here) or the laziness of the people in doing it. At the same time, there is clearly an high demand for supporting this. I think that:
|
Why do you think it's pointless? It seems to me that people are just trying to avoid duplication, by tying Sentry to Monolog and logging just once, but getting the same info in two places (logs and Sentry). Otherwise you're forced to duplicate code everywhere you log something. |
This is what the Python SDK does, it attaches all logger "context" to sentry extras. However what I would strongly recommend against is to create tags/user context out of logger context based on specially named "context keys" |
Because as I told a lot of times, in the logger context you can put a lot of data, from whole entities to punctual information, and copying everything blindly to Sentry just pollutes the information by hiding the interesting things, increase the size of the event to be sent and is more likely to make the server answer with the HTTP status code |
Excuse me, I don't want to sound rude, and I will not pollute the issue section with more comments like this: the request is for documentation, and if I was asking for it was not because of laziness, because I've spent a good couple of days of work and personal time because the effort was worth and valuable to me.
At least for me, this argument has been clear enough on each and every one of the issues I've visited, and I've never argued against it, but I was constantly redirected to outdated issues with partially working solutions, and non maintained 3rd party frameworks for previous versions of the current SDK. Even after that, there has been another amount of work noticing more caveats (for example, decorating the class pollutes the stacktraces making all the registered messages looking like they come from the same place. Was it easy to fix in the end? Yes. I've spent a lot of hours that I could have saved for resting or working on other things if this was documented? Yes. It's expectable to see people looking for a feature like this, especially if it was supported before? Hell yes. Could it be supported by just activating a flag? In my humble opinion, yes. Would I've been more than happy just with documentation? omgrofllmaoyes. My personal issue is solved, and I know how to do it (until the next SDK major update I guess). I just wonder how many issues will get reported asking for the same feature support, or a documented alternative, answered each day with bigger desperation, wondering why people are so lazy (or stupid), and reaffirming how pointless is to clarify the decision on the right place and providing the documentation to do it yourself. |
(I have placed some excerpts from https://develop.sentry.dev/sdk/philosophy/ in this comment to clarify a few points and reasoning why that point might be correct for the Sentry SDK) I have to kind of agree here, I don't see the pushback for an entirely optional feature and/or page in the documentation with just the exact code you can copy/pasta and modify. If you don't like it @ste93cry I can understand, but since it's optional and lot of people do like it I think it's at least worth considering it instead of being a hard no. And I think adding the class ourselfs or just documenting what you need to create is a very good thing to do considering the amount of questions we get and there not being a definitive answer and indeed every answer is incomplete and expects people to be Monolog/Symfony masters to get started with.
I hoped to get the an answer on how to do it correctly and in the best way (since I don't know it myself, especially in Symfony context) so I could create a doc page. Instead we are discussing
I think adding a doc page with the implementation people can start using is a great place to start, having a class in the SDK people can just require / implement is even better and totally in line with the SDK philosophy IMHO. So long story short, I think we either document it or built it into the SDK and document how to use it. Let's make that happen!? |
My comment was not directed towards you or anyone in particular, it's just a matter of facts that a lot of time requests are opened without people even reading the documentation or trying on their own before and expecting things to just be laid on the table by someone else
I would expect this to happen because you are logging a message without an exception, aren't you? In that case, since there is no stacktrace we can use, we use the
I didn't mean to offend anyone, of course, and I never intended to mean that people are stupid. However, I don't think that there is the need for a manual to use the decorator pattern and with the help of the already available documentation which explains the basic of the SDK come up with a solution. The Symfony documentation instead, is self-explanatory on how to wire up a service decorating another one.
I think there are two distinct things to say here. First of all, I never said I'm against documenting how to do this, if it helps people and prevents more and more issues being opened regarding the same thing. The second thing is that I'm opposed to adding the feature to the SDK for the reasons I explained before and because I was totally convinced that in the Python SDK this was clearly something unwanted. Maybe I wrongly interpreted the comment from @untitaker since the beginning, maybe things changed in the meanwhile, but if there is a precedent and this precedent is the standard for the SDKs then I see no problem in jumping into the boat even though I think it's the wrong choice
I think that at this point it's clear that the majority wants this feature, users asked for this from when it was dropped from the PHP SDK 2.0 and there are precedent like Laraval and the Python SDK that do this. By having this feature in the core SDK, all users will be able to use it without more work on the framework's integrations. Disclaimer, just for the sake of clarity: I don't work for Sentry, so those are my opinions as a contributor of the PHP SDK and nothing more |
I've tagged this as in the backlog for the moment as it seems like some documentation will need to be created here. @stayallive, are you comfortable having this assigned to you? |
Yep sounds good. We are working on some SDK changes and I'll make sure the documentation will be updated once those changes are incorporated and I know what it's going to look like 👍 |
For those who are still wondering how to add context to sentry log, just add
|
Routing to @getsentry/product-owners-apis for triage ⏲️ |
@stayallive Are these changes complete, and have you updated the docs? If yes, let's close this issue
|
Core or SDK?
Platform/SDK
Which part? Which one?
sentry/sentry-symfony package
Description
In the Symfony integration guide there is some documentation to integrate it with Monolog: https://docs.sentry.io/platforms/php/guides/symfony/
I'm going crazy between closed issues and non-working examples for old versions of the SDK to send a message with Monolog, adding the message's own context, for example:
Suggested Solution
Add a definitive documentation for current version to add the capacity to log Monolog's message context to Sentry's log
The text was updated successfully, but these errors were encountered: