Skip to content

Commit 46847cf

Browse files
ES|QL: make telemetry more strict (elastic#126940)
1 parent 604df82 commit 46847cf

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
@@ -37,7 +37,7 @@ setup:
3737
- do: {xpack.usage: {}}
3838
- match: { esql.available: true }
3939
- match: { esql.enabled: true }
40-
- length: { esql.features: 15 }
40+
- length: { esql.features: 25 }
4141
- set: {esql.features.dissect: dissect_counter}
4242
- set: {esql.features.drop: drop_counter}
4343
- set: {esql.features.eval: eval_counter}
@@ -53,6 +53,16 @@ setup:
5353
- set: {esql.features.sort: sort_counter}
5454
- set: {esql.features.stats: stats_counter}
5555
- set: {esql.features.where: where_counter}
56+
- set: {esql.features.lookup_join: lookup_join_counter}
57+
- set: {esql.features.lookup: lookup_counter}
58+
- set: {esql.features.change_point: change_point_counter}
59+
- set: {esql.features.inlinestats: inlinestats_counter}
60+
- set: {esql.features.rerank: rerank_counter}
61+
- set: {esql.features.dedup: dedup_counter}
62+
- set: {esql.features.insist: insist_counter}
63+
- set: {esql.features.fork: fork_counter}
64+
- set: {esql.features.rrf: rrf_counter}
65+
- set: {esql.features.completion: completion_counter}
5666
- length: { esql.queries: 3 }
5767
- set: {esql.queries.rest.total: rest_total_counter}
5868
- set: {esql.queries.rest.failed: rest_failed_counter}
@@ -81,6 +91,16 @@ setup:
8191
- gt: {esql.features.sort: $sort_counter}
8292
- gt: {esql.features.stats: $stats_counter}
8393
- gt: {esql.features.where: $where_counter}
94+
- match: {esql.features.lookup_join: $lookup_join_counter}
95+
- match: {esql.features.lookup: $lookup_counter}
96+
- match: {esql.features.change_point: $change_point_counter}
97+
- match: {esql.features.inlinestats: $inlinestats_counter}
98+
- match: {esql.features.rerank: $rerank_counter}
99+
- match: {esql.features.dedup: $dedup_counter}
100+
- match: {esql.features.insist: $insist_counter}
101+
- match: {esql.features.fork: $fork_counter}
102+
- match: {esql.features.rrf: $rrf_counter}
103+
- match: {esql.features.completion: $completion_counter}
84104
- gt: {esql.queries.rest.total: $rest_total_counter}
85105
- match: {esql.queries.rest.failed: $rest_failed_counter}
86106
- match: {esql.queries.kibana.total: $kibana_total_counter}
@@ -109,7 +129,7 @@ setup:
109129
- do: {xpack.usage: {}}
110130
- match: { esql.available: true }
111131
- match: { esql.enabled: true }
112-
- length: { esql.features: 15 }
132+
- length: { esql.features: 25 }
113133
- set: {esql.features.dissect: dissect_counter}
114134
- set: {esql.features.drop: drop_counter}
115135
- set: {esql.features.eval: eval_counter}
@@ -125,6 +145,16 @@ setup:
125145
- set: {esql.features.sort: sort_counter}
126146
- set: {esql.features.stats: stats_counter}
127147
- set: {esql.features.where: where_counter}
148+
- set: {esql.features.lookup_join: lookup_join_counter}
149+
- set: {esql.features.lookup: lookup_counter}
150+
- set: {esql.features.change_point: change_point_counter}
151+
- set: {esql.features.inlinestats: inlinestats_counter}
152+
- set: {esql.features.rerank: rerank_counter}
153+
- set: {esql.features.dedup: dedup_counter}
154+
- set: {esql.features.insist: insist_counter}
155+
- set: {esql.features.fork: fork_counter}
156+
- set: {esql.features.rrf: rrf_counter}
157+
- set: {esql.features.completion: completion_counter}
128158
- length: { esql.queries: 3 }
129159
- set: {esql.queries.rest.total: rest_total_counter}
130160
- set: {esql.queries.rest.failed: rest_failed_counter}
@@ -153,6 +183,16 @@ setup:
153183
- gt: {esql.features.sort: $sort_counter}
154184
- gt: {esql.features.stats: $stats_counter}
155185
- gt: {esql.features.where: $where_counter}
186+
- match: {esql.features.lookup_join: $lookup_join_counter}
187+
- match: {esql.features.lookup: $lookup_counter}
188+
- match: {esql.features.change_point: $change_point_counter}
189+
- match: {esql.features.inlinestats: $inlinestats_counter}
190+
- match: {esql.features.rerank: $rerank_counter}
191+
- match: {esql.features.dedup: $dedup_counter}
192+
- match: {esql.features.insist: $insist_counter}
193+
- match: {esql.features.fork: $fork_counter}
194+
- match: {esql.features.rrf: $rrf_counter}
195+
- match: {esql.features.completion: $completion_counter}
156196
- gt: {esql.queries.rest.total: $rest_total_counter}
157197
- match: {esql.queries.rest.failed: $rest_failed_counter}
158198
- match: {esql.queries.kibana.total: $kibana_total_counter}

0 commit comments

Comments
 (0)