- Notifications
You must be signed in to change notification settings - Fork 25.6k
Add trace log of the request for the query and fetch phases #34479
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
Conversation
This query adds a logger for the query and fetch phases that prints all requests before their execution at the trace level. This will help debugging cases where an issue occurs during the execution since only completed queries are logged by the slow logs.
| Pinging @elastic/es-search-aggs |
romseygeek left a comment
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. It would be nice to be able to associate an ID with the query to match up query and fetch phases, but I guess that can be done as part of the query body itself?
Good idea, I added the |
danielmitterdorfer left a comment
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.
Thanks for doing this! I left a few comments on how to avoid some overhead.
| */ | ||
| void execute(SearchContext context); | ||
| | ||
| class SearchContextRequestLog { |
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 think this can be declared as static to avoid capturing the enclosing class' state? Further looking at the usage, I wonder whether this should actually be a static method to avoid creating garbage for every query?
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.
This declaration is within an interface so the static modifier is redundant, this is a static nested class already.
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.
Ah, good point. I did not check that.
| @Override | ||
| public void execute(SearchContext context) { | ||
| | ||
| LOGGER.trace("{}", new SearchContextRequestLog(context)); |
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.
It might make sense to guard this log statement? (i.e. if LOGGER.isTraceEnabled())?)
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.
++, this will avoid the creation of a new object on each query
| return; | ||
| } | ||
| | ||
| LOGGER.trace("{}", new SearchContextRequestLog(searchContext)); |
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.
It might make sense to guard this log statement? (i.e. if LOGGER.isTraceEnabled())?)
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.
thanks
danielmitterdorfer left a comment
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.
Thanks for iterating. LGTM!
This change adds a logger for the query and fetch phases that prints all requests before their execution at the trace level. This will help debugging cases where an issue occurs during the execution since only completed queries are logged by the slow logs.
This change adds a logger for the query and fetch phases that prints all requests
before their execution at the trace level. This will help debugging cases where an issue
occurs during the execution since only completed queries are logged by the slow logs.