Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,25 @@
public abstract class RuleExecutor<TreeType extends Node<TreeType>> {

private final Logger log = LogManager.getLogger(getClass());
/**
* Sub-logger intended to show only changes made by the rules. Intended for debugging.
*
* Enable it like this for the respective optimizers and the analyzer, resp. all inheritors of this class:
* <pre>{@code
* PUT localhost:9200/_cluster/settings
*
* {
* "transient" : {
* "logger.org.elasticsearch.xpack.esql.analysis.Analyzer.changes": "TRACE",
* "logger.org.elasticsearch.xpack.esql.optimizer.LogicalPlanOptimizer.changes": "TRACE",
* "logger.org.elasticsearch.xpack.esql.optimizer.LocalLogicalPlanOptimizer.changes": "TRACE",
* "logger.org.elasticsearch.xpack.esql.optimizer.PhysicalPlanOptimizer.changes": "TRACE",
* "logger.org.elasticsearch.xpack.esql.optimizer.LocalPhysicalPlanOptimizer.changes": "TRACE"
* }
* }
* }</pre>
*/
private final Logger changeLog = LogManager.getLogger(getClass().getName() + ".changes");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You tested this locally, right? I'm pretty sure this is right, but I can't write code without some kind of mistake.

Copy link
Contributor Author

@alex-spies alex-spies Aug 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++ confirmed locally that
a) this does not accidentally exclude the changes in query plans when turning trace logging on for logger.org.elasticsearch.xpack.esql, and
b) you can, indeed, enable the changes logger for each individual optimizer/analyzer, separately, using the instructions from the javadoc.

Ideally, we'd have a test for this, but I don't know that we already test the trace logs anywhere; setting up tests for this small change might be a bit high effort compared to the change.


public static class Limiter {
public static final Limiter DEFAULT = new Limiter(100);
Expand Down Expand Up @@ -174,8 +193,8 @@ protected final ExecutionInfo executeWithInfo(TreeType plan) {

if (tf.hasChanged()) {
hasChanged = true;
if (log.isTraceEnabled()) {
log.trace("Rule {} applied with change\n{}", rule, NodeUtils.diffString(tf.before, tf.after));
if (changeLog.isTraceEnabled()) {
changeLog.trace("Rule {} applied with change\n{}", rule, NodeUtils.diffString(tf.before, tf.after));
}
} else {
if (log.isTraceEnabled()) {
Expand Down