Skip to content

Commit 6b8c37e

Browse files
ES|QL: make telemetry more strict (#126940)
1 parent 4b05fed commit 6b8c37e

File tree

2 files changed

+86
-3
lines changed
  • x-pack/plugin

2 files changed

+86
-3
lines changed

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/telemetry/FeatureMetric.java

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,39 @@
77

88
package org.elasticsearch.xpack.esql.telemetry;
99

10+
import org.elasticsearch.xpack.esql.EsqlIllegalArgumentException;
1011
import org.elasticsearch.xpack.esql.plan.logical.Aggregate;
12+
import org.elasticsearch.xpack.esql.plan.logical.ChangePoint;
13+
import org.elasticsearch.xpack.esql.plan.logical.Dedup;
1114
import org.elasticsearch.xpack.esql.plan.logical.Dissect;
1215
import org.elasticsearch.xpack.esql.plan.logical.Drop;
1316
import org.elasticsearch.xpack.esql.plan.logical.Enrich;
1417
import org.elasticsearch.xpack.esql.plan.logical.EsRelation;
1518
import org.elasticsearch.xpack.esql.plan.logical.Eval;
1619
import org.elasticsearch.xpack.esql.plan.logical.Filter;
20+
import org.elasticsearch.xpack.esql.plan.logical.Fork;
1721
import org.elasticsearch.xpack.esql.plan.logical.Grok;
22+
import org.elasticsearch.xpack.esql.plan.logical.InlineStats;
23+
import org.elasticsearch.xpack.esql.plan.logical.Insist;
1824
import org.elasticsearch.xpack.esql.plan.logical.Keep;
25+
import org.elasticsearch.xpack.esql.plan.logical.Limit;
1926
import org.elasticsearch.xpack.esql.plan.logical.LogicalPlan;
27+
import org.elasticsearch.xpack.esql.plan.logical.Lookup;
2028
import org.elasticsearch.xpack.esql.plan.logical.MvExpand;
2129
import org.elasticsearch.xpack.esql.plan.logical.OrderBy;
30+
import org.elasticsearch.xpack.esql.plan.logical.Project;
2231
import org.elasticsearch.xpack.esql.plan.logical.Rename;
2332
import org.elasticsearch.xpack.esql.plan.logical.Row;
33+
import org.elasticsearch.xpack.esql.plan.logical.RrfScoreEval;
34+
import org.elasticsearch.xpack.esql.plan.logical.UnresolvedRelation;
35+
import org.elasticsearch.xpack.esql.plan.logical.inference.Completion;
36+
import org.elasticsearch.xpack.esql.plan.logical.inference.Rerank;
37+
import org.elasticsearch.xpack.esql.plan.logical.join.LookupJoin;
38+
import org.elasticsearch.xpack.esql.plan.logical.local.EsqlProject;
2439
import org.elasticsearch.xpack.esql.plan.logical.show.ShowInfo;
2540

2641
import java.util.BitSet;
42+
import java.util.List;
2743
import java.util.Locale;
2844
import java.util.function.Predicate;
2945

@@ -42,7 +58,27 @@ public enum FeatureMetric {
4258
FROM(EsRelation.class::isInstance),
4359
DROP(Drop.class::isInstance),
4460
KEEP(Keep.class::isInstance),
45-
RENAME(Rename.class::isInstance);
61+
RENAME(Rename.class::isInstance),
62+
LOOKUP_JOIN(LookupJoin.class::isInstance),
63+
LOOKUP(Lookup.class::isInstance),
64+
CHANGE_POINT(ChangePoint.class::isInstance),
65+
INLINESTATS(InlineStats.class::isInstance),
66+
RERANK(Rerank.class::isInstance),
67+
DEDUP(Dedup.class::isInstance),
68+
INSIST(Insist.class::isInstance),
69+
FORK(Fork.class::isInstance),
70+
RRF(RrfScoreEval.class::isInstance),
71+
COMPLETION(Completion.class::isInstance);
72+
73+
/**
74+
* List here plans we want to exclude from telemetry
75+
*/
76+
private static final List<Class<? extends LogicalPlan>> excluded = List.of(
77+
UnresolvedRelation.class,
78+
EsqlProject.class,
79+
Project.class,
80+
Limit.class // LIMIT is managed in another way, see above
81+
);
4682

4783
private Predicate<LogicalPlan> planCheck;
4884

@@ -61,6 +97,13 @@ public static void set(LogicalPlan plan, BitSet bitset) {
6197
return;
6298
}
6399
}
100+
if (explicitlyExcluded(plan) == false) {
101+
throw new EsqlIllegalArgumentException("Command not mapped for telemetry [{}]", plan.getClass().getSimpleName());
102+
}
103+
}
104+
105+
private static boolean explicitlyExcluded(LogicalPlan plan) {
106+
return excluded.stream().anyMatch(x -> x.isInstance(plan));
64107
}
65108

66109
public static boolean set(LogicalPlan plan, BitSet bitset, FeatureMetric metric) {

x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/60_usage.yml

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ setup:
3939
- do: {xpack.usage: {}}
4040
- match: { esql.available: true }
4141
- match: { esql.enabled: true }
42-
- length: { esql.features: 15 }
42+
- length: { esql.features: 25 }
4343
- set: {esql.features.dissect: dissect_counter}
4444
- set: {esql.features.drop: drop_counter}
4545
- set: {esql.features.eval: eval_counter}
@@ -55,6 +55,16 @@ setup:
5555
- set: {esql.features.sort: sort_counter}
5656
- set: {esql.features.stats: stats_counter}
5757
- set: {esql.features.where: where_counter}
58+
- set: {esql.features.lookup_join: lookup_join_counter}
59+
- set: {esql.features.lookup: lookup_counter}
60+
- set: {esql.features.change_point: change_point_counter}
61+
- set: {esql.features.inlinestats: inlinestats_counter}
62+
- set: {esql.features.rerank: rerank_counter}
63+
- set: {esql.features.dedup: dedup_counter}
64+
- set: {esql.features.insist: insist_counter}
65+
- set: {esql.features.fork: fork_counter}
66+
- set: {esql.features.rrf: rrf_counter}
67+
- set: {esql.features.completion: completion_counter}
5868
- length: { esql.queries: 3 }
5969
- set: {esql.queries.rest.total: rest_total_counter}
6070
- set: {esql.queries.rest.failed: rest_failed_counter}
@@ -88,6 +98,16 @@ setup:
8898
- gt: {esql.features.sort: $sort_counter}
8999
- gt: {esql.features.stats: $stats_counter}
90100
- gt: {esql.features.where: $where_counter}
101+
- match: {esql.features.lookup_join: $lookup_join_counter}
102+
- match: {esql.features.lookup: $lookup_counter}
103+
- match: {esql.features.change_point: $change_point_counter}
104+
- match: {esql.features.inlinestats: $inlinestats_counter}
105+
- match: {esql.features.rerank: $rerank_counter}
106+
- match: {esql.features.dedup: $dedup_counter}
107+
- match: {esql.features.insist: $insist_counter}
108+
- match: {esql.features.fork: $fork_counter}
109+
- match: {esql.features.rrf: $rrf_counter}
110+
- match: {esql.features.completion: $completion_counter}
91111
- gt: {esql.queries.rest.total: $rest_total_counter}
92112
- match: {esql.queries.rest.failed: $rest_failed_counter}
93113
- match: {esql.queries.kibana.total: $kibana_total_counter}
@@ -117,7 +137,7 @@ setup:
117137
- do: {xpack.usage: {}}
118138
- match: { esql.available: true }
119139
- match: { esql.enabled: true }
120-
- length: { esql.features: 15 }
140+
- length: { esql.features: 25 }
121141
- set: {esql.features.dissect: dissect_counter}
122142
- set: {esql.features.drop: drop_counter}
123143
- set: {esql.features.eval: eval_counter}
@@ -133,6 +153,16 @@ setup:
133153
- set: {esql.features.sort: sort_counter}
134154
- set: {esql.features.stats: stats_counter}
135155
- set: {esql.features.where: where_counter}
156+
- set: {esql.features.lookup_join: lookup_join_counter}
157+
- set: {esql.features.lookup: lookup_counter}
158+
- set: {esql.features.change_point: change_point_counter}
159+
- set: {esql.features.inlinestats: inlinestats_counter}
160+
- set: {esql.features.rerank: rerank_counter}
161+
- set: {esql.features.dedup: dedup_counter}
162+
- set: {esql.features.insist: insist_counter}
163+
- set: {esql.features.fork: fork_counter}
164+
- set: {esql.features.rrf: rrf_counter}
165+
- set: {esql.features.completion: completion_counter}
136166
- length: { esql.queries: 3 }
137167
- set: {esql.queries.rest.total: rest_total_counter}
138168
- set: {esql.queries.rest.failed: rest_failed_counter}
@@ -166,6 +196,16 @@ setup:
166196
- gt: {esql.features.sort: $sort_counter}
167197
- gt: {esql.features.stats: $stats_counter}
168198
- gt: {esql.features.where: $where_counter}
199+
- match: {esql.features.lookup_join: $lookup_join_counter}
200+
- match: {esql.features.lookup: $lookup_counter}
201+
- match: {esql.features.change_point: $change_point_counter}
202+
- match: {esql.features.inlinestats: $inlinestats_counter}
203+
- match: {esql.features.rerank: $rerank_counter}
204+
- match: {esql.features.dedup: $dedup_counter}
205+
- match: {esql.features.insist: $insist_counter}
206+
- match: {esql.features.fork: $fork_counter}
207+
- match: {esql.features.rrf: $rrf_counter}
208+
- match: {esql.features.completion: $completion_counter}
169209
- gt: {esql.queries.rest.total: $rest_total_counter}
170210
- match: {esql.queries.rest.failed: $rest_failed_counter}
171211
- match: {esql.queries.kibana.total: $kibana_total_counter}

0 commit comments

Comments
 (0)