Skip to content
Merged
Show file tree
Hide file tree
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 @@ -7,6 +7,7 @@

package org.elasticsearch.xpack.esql.telemetry;

import org.elasticsearch.xpack.esql.EsqlIllegalArgumentException;
import org.elasticsearch.xpack.esql.plan.logical.Aggregate;
import org.elasticsearch.xpack.esql.plan.logical.Dissect;
import org.elasticsearch.xpack.esql.plan.logical.Drop;
Expand All @@ -15,15 +16,24 @@
import org.elasticsearch.xpack.esql.plan.logical.Eval;
import org.elasticsearch.xpack.esql.plan.logical.Filter;
import org.elasticsearch.xpack.esql.plan.logical.Grok;
import org.elasticsearch.xpack.esql.plan.logical.InlineStats;
import org.elasticsearch.xpack.esql.plan.logical.Insist;
import org.elasticsearch.xpack.esql.plan.logical.Keep;
import org.elasticsearch.xpack.esql.plan.logical.Limit;
import org.elasticsearch.xpack.esql.plan.logical.LogicalPlan;
import org.elasticsearch.xpack.esql.plan.logical.Lookup;
import org.elasticsearch.xpack.esql.plan.logical.MvExpand;
import org.elasticsearch.xpack.esql.plan.logical.OrderBy;
import org.elasticsearch.xpack.esql.plan.logical.Project;
import org.elasticsearch.xpack.esql.plan.logical.Rename;
import org.elasticsearch.xpack.esql.plan.logical.Row;
import org.elasticsearch.xpack.esql.plan.logical.UnresolvedRelation;
import org.elasticsearch.xpack.esql.plan.logical.join.LookupJoin;
import org.elasticsearch.xpack.esql.plan.logical.local.EsqlProject;
import org.elasticsearch.xpack.esql.plan.logical.show.ShowInfo;

import java.util.BitSet;
import java.util.List;
import java.util.Locale;
import java.util.function.Predicate;

Expand All @@ -42,7 +52,21 @@ public enum FeatureMetric {
FROM(EsRelation.class::isInstance),
DROP(Drop.class::isInstance),
KEEP(Keep.class::isInstance),
RENAME(Rename.class::isInstance);
RENAME(Rename.class::isInstance),
LOOKUP_JOIN(LookupJoin.class::isInstance),
LOOKUP(Lookup.class::isInstance),
INLINESTATS(InlineStats.class::isInstance),
INSIST(Insist.class::isInstance);

/**
* List here plans we want to exclude from telemetry
*/
private static final List<Class<? extends LogicalPlan>> excluded = List.of(
UnresolvedRelation.class,
EsqlProject.class,
Project.class,
Limit.class // LIMIT is managed in another way, see above
);

private Predicate<LogicalPlan> planCheck;

Expand All @@ -61,6 +85,13 @@ public static void set(LogicalPlan plan, BitSet bitset) {
return;
}
}
if (explicitlyExcluded(plan) == false) {
throw new EsqlIllegalArgumentException("Command not mapped for telemetry [{}]", plan.getClass().getSimpleName());
}
}

private static boolean explicitlyExcluded(LogicalPlan plan) {
return excluded.stream().anyMatch(x -> x.isInstance(plan));
}

public static boolean set(LogicalPlan plan, BitSet bitset, FeatureMetric metric) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ setup:
- do: {xpack.usage: {}}
- match: { esql.available: true }
- match: { esql.enabled: true }
- length: { esql.features: 15 }
- length: { esql.features: 19 }
- set: {esql.features.dissect: dissect_counter}
- set: {esql.features.drop: drop_counter}
- set: {esql.features.eval: eval_counter}
Expand All @@ -53,6 +53,10 @@ setup:
- set: {esql.features.sort: sort_counter}
- set: {esql.features.stats: stats_counter}
- set: {esql.features.where: where_counter}
- set: {esql.features.lookup_join: lookup_join_counter}
- set: {esql.features.lookup: lookup_counter}
- set: {esql.features.inlinestats: inlinestats_counter}
- set: {esql.features.insist: insist_counter}
- length: { esql.queries: 3 }
- set: {esql.queries.rest.total: rest_total_counter}
- set: {esql.queries.rest.failed: rest_failed_counter}
Expand Down Expand Up @@ -81,6 +85,10 @@ setup:
- gt: {esql.features.sort: $sort_counter}
- gt: {esql.features.stats: $stats_counter}
- gt: {esql.features.where: $where_counter}
- match: {esql.features.lookup_join: $lookup_join_counter}
- match: {esql.features.lookup: $lookup_counter}
- match: {esql.features.inlinestats: $inlinestats_counter}
- match: {esql.features.insist: $insist_counter}
- gt: {esql.queries.rest.total: $rest_total_counter}
- match: {esql.queries.rest.failed: $rest_failed_counter}
- match: {esql.queries.kibana.total: $kibana_total_counter}
Expand Down Expand Up @@ -109,7 +117,7 @@ setup:
- do: {xpack.usage: {}}
- match: { esql.available: true }
- match: { esql.enabled: true }
- length: { esql.features: 15 }
- length: { esql.features: 19 }
- set: {esql.features.dissect: dissect_counter}
- set: {esql.features.drop: drop_counter}
- set: {esql.features.eval: eval_counter}
Expand All @@ -125,6 +133,10 @@ setup:
- set: {esql.features.sort: sort_counter}
- set: {esql.features.stats: stats_counter}
- set: {esql.features.where: where_counter}
- set: {esql.features.lookup_join: lookup_join_counter}
- set: {esql.features.lookup: lookup_counter}
- set: {esql.features.inlinestats: inlinestats_counter}
- set: {esql.features.insist: insist_counter}
- length: { esql.queries: 3 }
- set: {esql.queries.rest.total: rest_total_counter}
- set: {esql.queries.rest.failed: rest_failed_counter}
Expand Down Expand Up @@ -153,6 +165,10 @@ setup:
- gt: {esql.features.sort: $sort_counter}
- gt: {esql.features.stats: $stats_counter}
- gt: {esql.features.where: $where_counter}
- match: {esql.features.lookup_join: $lookup_join_counter}
- match: {esql.features.lookup: $lookup_counter}
- match: {esql.features.inlinestats: $inlinestats_counter}
- match: {esql.features.insist: $insist_counter}
- gt: {esql.queries.rest.total: $rest_total_counter}
- match: {esql.queries.rest.failed: $rest_failed_counter}
- match: {esql.queries.kibana.total: $kibana_total_counter}
Expand Down