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
Add query backtrace logger #3513
Conversation
|
||
namespace Doctrine\DBAL\Logging; | ||
|
||
class BacktraceLogger extends DebugStack |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd avoid coupling the BacktraceLogger
to the existing DebugStack
one, if possible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, the whole point here is to add the backtrace into the data stored for each query. Not coupling it would defeat the point.
Links to previous attempts: #3390 , #535 , #719 cc @pierredup @carnage @dmecke . People want that feature badly, it would be great to have a list of requirements for its implementation somewhere.
|
Thank you @greg0ire for this summary 👍
|
Regarding #4 and #719 (comment), after trying to implement a PSR-3 adapter (#3156) and later reading an article on Domain-Oriented Observability, I realized that our logger is not really a logger. It's a probe. It allows plugging in loggers, metrics and their combinations. I'm still not convinced that we should be adding any new implementations to the stack. As long as the interface allows for extensibility, the needed functionality can be part of the application which needs it or a separate package. |
@morozov well, if we use that feature in DoctrineBundle itself, it means that the implementation would be maintained by Doctrine anyway. Then, having it in DBAL itself means that other framework integrations can also use it directly instead of having to copy it from DoctrineBundle. |
@Ocramius can you maybe help with this? I don't understand what you are suggesting either (composition, copy/paste, something else entirely, no suggestion?) |
I'm suggesting c&p and avoiding the inheritance
…On Sat, 27 Apr 2019, 15:23 Grégoire Paris, ***@***.***> wrote:
honesty I don't really see how to do it :) with DebugStack public
properties
@Ocramius <https://github.com/Ocramius> can you maybe help with this? I
don't understand what you are suggesting either (composition, copy/paste,
something else entirely, no suggestion?)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3513 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AABFVEDMYH35NCTJA4DDYS3PSRHWHANCNFSM4HFZHDZA>
.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. inheritance > c&p
Disagree massively: adding inheritance reduces our ability to introduce international changes. If inheritance is not also introducing added "meaning", it is absolutely NEVER to be used as a code reuse mechanism. |
If this goes towards copy and paste, would you say public properties should be kept, or should encapsulation be used this time? |
Considering how widespread the library is, I'd at least use a safer API around here, because properties are invariants, therefore they expose a BC surface both for reads and writes. In other words: yes, we'd need some sort of accessors/reset methods. |
Thinking more about API and state, @morozov got to the right thought at #3513 (comment) The logger being the primary reason why doctrine has memleaks in symfony-related setuos (think profiler), maybe it is a good idea if we didn't even have a logger ourselves at all, and instead only provided the hook mechanism? |
Finally got around to reading the article linked by @morozov , that was really a great read! Just to be clear, are you saying that the |
I didn't think of it in these details but sounds right. I believe everyone would benefit from having code closer to the owner in order to avoid unproductive discussions and wasted effort. I do believe that neither On the other hand, in my own experience of developing DBAL, having |
Looks like we have reached an agreement :) @ottaviano, I think you can close this PR and make your bundle PR independent from it by adding a new SqlLogger implementation to it. |
Closing here as per #3513 (comment) |
For the record, while I agree with the semantics surrounding I'm all for cleaning up the API and dropping the current Regarding decoupling from |
Which is natural. As long as observability logic can be framework-specific, it's fine to have separate implementations in each bundle/module.
Which is also fine. People may have different needs than frameworks. Besides that, the current implementation of
Frameworks may define their own interfaces for data retrieval. An instrumentation component can implement both |
Summary
inspired by doctrine-stats I think it'll be nice to log backtrace of each query.
use case with doctrine-bundle:
doctrine-bundle pull request