Skip to content

ES|QL: make telemetry more strict #126940

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

Merged
merged 4 commits into from
Apr 17, 2025
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,23 +7,39 @@

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.ChangePoint;
import org.elasticsearch.xpack.esql.plan.logical.Dedup;
import org.elasticsearch.xpack.esql.plan.logical.Dissect;
import org.elasticsearch.xpack.esql.plan.logical.Drop;
import org.elasticsearch.xpack.esql.plan.logical.Enrich;
import org.elasticsearch.xpack.esql.plan.logical.EsRelation;
import org.elasticsearch.xpack.esql.plan.logical.Eval;
import org.elasticsearch.xpack.esql.plan.logical.Filter;
import org.elasticsearch.xpack.esql.plan.logical.Fork;
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.RrfScoreEval;
import org.elasticsearch.xpack.esql.plan.logical.UnresolvedRelation;
import org.elasticsearch.xpack.esql.plan.logical.inference.Completion;
import org.elasticsearch.xpack.esql.plan.logical.inference.Rerank;
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 +58,27 @@ 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),
CHANGE_POINT(ChangePoint.class::isInstance),
INLINESTATS(InlineStats.class::isInstance),
RERANK(Rerank.class::isInstance),
DEDUP(Dedup.class::isInstance),
INSIST(Insist.class::isInstance),
FORK(Fork.class::isInstance),
RRF(RrfScoreEval.class::isInstance),
COMPLETION(Completion.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 +97,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 @@ -39,7 +39,7 @@ setup:
- do: {xpack.usage: {}}
- match: { esql.available: true }
- match: { esql.enabled: true }
- length: { esql.features: 15 }
- length: { esql.features: 25 }
- set: {esql.features.dissect: dissect_counter}
- set: {esql.features.drop: drop_counter}
- set: {esql.features.eval: eval_counter}
Expand All @@ -55,6 +55,16 @@ 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.change_point: change_point_counter}
- set: {esql.features.inlinestats: inlinestats_counter}
- set: {esql.features.rerank: rerank_counter}
- set: {esql.features.dedup: dedup_counter}
- set: {esql.features.insist: insist_counter}
- set: {esql.features.fork: fork_counter}
- set: {esql.features.rrf: rrf_counter}
- set: {esql.features.completion: completion_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 @@ -88,6 +98,16 @@ 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.change_point: $change_point_counter}
- match: {esql.features.inlinestats: $inlinestats_counter}
- match: {esql.features.rerank: $rerank_counter}
- match: {esql.features.dedup: $dedup_counter}
- match: {esql.features.insist: $insist_counter}
- match: {esql.features.fork: $fork_counter}
- match: {esql.features.rrf: $rrf_counter}
- match: {esql.features.completion: $completion_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 @@ -117,7 +137,7 @@ setup:
- do: {xpack.usage: {}}
- match: { esql.available: true }
- match: { esql.enabled: true }
- length: { esql.features: 15 }
- length: { esql.features: 25 }
- set: {esql.features.dissect: dissect_counter}
- set: {esql.features.drop: drop_counter}
- set: {esql.features.eval: eval_counter}
Expand All @@ -133,6 +153,16 @@ 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.change_point: change_point_counter}
- set: {esql.features.inlinestats: inlinestats_counter}
- set: {esql.features.rerank: rerank_counter}
- set: {esql.features.dedup: dedup_counter}
- set: {esql.features.insist: insist_counter}
- set: {esql.features.fork: fork_counter}
- set: {esql.features.rrf: rrf_counter}
- set: {esql.features.completion: completion_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 @@ -166,6 +196,16 @@ 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.change_point: $change_point_counter}
- match: {esql.features.inlinestats: $inlinestats_counter}
- match: {esql.features.rerank: $rerank_counter}
- match: {esql.features.dedup: $dedup_counter}
- match: {esql.features.insist: $insist_counter}
- match: {esql.features.fork: $fork_counter}
- match: {esql.features.rrf: $rrf_counter}
- match: {esql.features.completion: $completion_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