-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Pass the exception into the stopQuery
.
#3170
Comments
@jcchavezs I like the idea. We do a similar thing in our project by using a custom connection wrapper class. There are a few things to keep in mind though:
Please file a pull request so that we could proceed. |
Hi Sergei,
Glad to see this is feasible.
@beberlei suggested we instead introduce a new interface (let say
SQLLoggerWithErrors) extending from SQLLogger that includes the method
`stopQueryWithError` and we pass the exception there. His idea is to check
if the logger is `instanceof` SQLLoggerWithErrors or SQLLogger and then
decide what method to use.
The advantage of this approach is that we have a meaningful method in
logger for errors. Otherwise, the initial proposal is still working for me
and this new interface can be added in v2.
Could you please give us some input so I can update my [PR](#3174)?
Thanks!
|
@jcchavezs personally, I think adding a new method is overkill given that there's a backward-compatible way of introducing the feature without adding a method. What I'm concerned about more, is that our logging API still doesn't comply with the Open/closed principle. Every time we want to add some details to logging, we need to change the API. There's an ongoing effort #3156 where we're trying to introduce the PSR-3 adapter but the Open/closed problem is still unsolved there. Maybe we could address both issues at once without changing the
Have you filed one? I cannot see any. |
Sorry, in the end I did not open it: #3174
I don't think the PSR3 introduction will solve the problem. To me, the problem with logger is that it was good enough by the time it was designed but now it is required to do more sophisticated instrumentation and changes are required: more information passed to the logger, call I would go for merging my PR and release a minor, what do you think? |
in addition to the exception, it would be useful if stopQuery also receives a |
Closing in favor of #4941. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Feature Request
The
SQLLogger::stopQuery
method does not receive any information about the output of the query.Summary
Problem 1: When calling
startQuery
,stopQuery
is always being called.stopQuery
is not being called when there is an exception thrown inConnection::executeQuery
,Connection::query
orConnection::exec
.This makes it impossible to finish any sort of
span
ortrace
once it is initialized instartQuery
.My proposal is that we add the
stopQuery
in thecatch
, same as inStatement::execute
.Problem 2: When calling
stopQuery
after an error, the error is not passed to thestopQuery
.Some more sophisticated logging or tracing require to report an error when it happens. The current SQLLogger implementation does not support that as
stopQuery
does not receive any parameter.Existing code in
Statement
does:So from the logger point of view the query finished but it has no more information about it.
Since
SQLLogger
is an interface, adding support for the parameter will break existing implementations and will be hard to release. I propose we don't change the interface and pass the exception as parameter, delegating the responsibility for clients to deal with that information. This can be released in a minor version in semver.In the future, we can change the interface of
SQLLogger
accepting the exception as parameter but that will be a breaking change and will require a major version.Another option is to pass
stopQuery(true)
instead of the exception itself.Ping: @beberlei @Ocramius @deeky666. I can open a PR if you feel this can be done.
PS for @beberlei you might want to see this problem with even more context in this issue: jcchavezs/zipkin-instrumentation-doctrine#1
The text was updated successfully, but these errors were encountered: