Skip to content

Commit d53a324

Browse files
[8.18] ES|QL: make telemetry more strict (#126940) (#126980)
* ES|QL: make telemetry more strict (#126940) * Fix compile * Fix tests * Fix test
1 parent 642d26e commit d53a324

File tree

3 files changed

+48
-4
lines changed

3 files changed

+48
-4
lines changed

docs/reference/rest-api/usage.asciidoc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,10 @@ GET /_xpack/usage
243243
"keep" : 0,
244244
"enrich" : 0,
245245
"from" : 0,
246-
"row" : 0
246+
"row" : 0,
247+
"lookup" : 0,
248+
"inlinestats" : 0,
249+
"lookup_join" : 0
247250
},
248251
"queries" : {
249252
"rest" : {

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

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
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;
1112
import org.elasticsearch.xpack.esql.plan.logical.Dissect;
1213
import org.elasticsearch.xpack.esql.plan.logical.Drop;
@@ -15,15 +16,23 @@
1516
import org.elasticsearch.xpack.esql.plan.logical.Eval;
1617
import org.elasticsearch.xpack.esql.plan.logical.Filter;
1718
import org.elasticsearch.xpack.esql.plan.logical.Grok;
19+
import org.elasticsearch.xpack.esql.plan.logical.InlineStats;
1820
import org.elasticsearch.xpack.esql.plan.logical.Keep;
21+
import org.elasticsearch.xpack.esql.plan.logical.Limit;
1922
import org.elasticsearch.xpack.esql.plan.logical.LogicalPlan;
23+
import org.elasticsearch.xpack.esql.plan.logical.Lookup;
2024
import org.elasticsearch.xpack.esql.plan.logical.MvExpand;
2125
import org.elasticsearch.xpack.esql.plan.logical.OrderBy;
26+
import org.elasticsearch.xpack.esql.plan.logical.Project;
2227
import org.elasticsearch.xpack.esql.plan.logical.Rename;
2328
import org.elasticsearch.xpack.esql.plan.logical.Row;
29+
import org.elasticsearch.xpack.esql.plan.logical.UnresolvedRelation;
30+
import org.elasticsearch.xpack.esql.plan.logical.join.LookupJoin;
31+
import org.elasticsearch.xpack.esql.plan.logical.local.EsqlProject;
2432
import org.elasticsearch.xpack.esql.plan.logical.show.ShowInfo;
2533

2634
import java.util.BitSet;
35+
import java.util.List;
2736
import java.util.Locale;
2837
import java.util.function.Predicate;
2938

@@ -42,7 +51,20 @@ public enum FeatureMetric {
4251
FROM(EsRelation.class::isInstance),
4352
DROP(Drop.class::isInstance),
4453
KEEP(Keep.class::isInstance),
45-
RENAME(Rename.class::isInstance);
54+
RENAME(Rename.class::isInstance),
55+
LOOKUP_JOIN(LookupJoin.class::isInstance),
56+
LOOKUP(Lookup.class::isInstance),
57+
INLINESTATS(InlineStats.class::isInstance);
58+
59+
/**
60+
* List here plans we want to exclude from telemetry
61+
*/
62+
private static final List<Class<? extends LogicalPlan>> excluded = List.of(
63+
UnresolvedRelation.class,
64+
EsqlProject.class,
65+
Project.class,
66+
Limit.class // LIMIT is managed in another way, see above
67+
);
4668

4769
private Predicate<LogicalPlan> planCheck;
4870

@@ -61,6 +83,13 @@ public static void set(LogicalPlan plan, BitSet bitset) {
6183
return;
6284
}
6385
}
86+
if (explicitlyExcluded(plan) == false) {
87+
throw new EsqlIllegalArgumentException("Command not mapped for telemetry [{}]", plan.getClass().getSimpleName());
88+
}
89+
}
90+
91+
private static boolean explicitlyExcluded(LogicalPlan plan) {
92+
return excluded.stream().anyMatch(x -> x.isInstance(plan));
6493
}
6594

6695
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: 14 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: 18 }
4141
- set: {esql.features.dissect: dissect_counter}
4242
- set: {esql.features.drop: drop_counter}
4343
- set: {esql.features.eval: eval_counter}
@@ -53,6 +53,9 @@ 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.inlinestats: inlinestats_counter}
5659
- length: { esql.queries: 3 }
5760
- set: {esql.queries.rest.total: rest_total_counter}
5861
- set: {esql.queries.rest.failed: rest_failed_counter}
@@ -81,6 +84,9 @@ setup:
8184
- gt: {esql.features.sort: $sort_counter}
8285
- gt: {esql.features.stats: $stats_counter}
8386
- gt: {esql.features.where: $where_counter}
87+
- match: {esql.features.lookup_join: $lookup_join_counter}
88+
- match: {esql.features.lookup: $lookup_counter}
89+
- match: {esql.features.inlinestats: $inlinestats_counter}
8490
- gt: {esql.queries.rest.total: $rest_total_counter}
8591
- match: {esql.queries.rest.failed: $rest_failed_counter}
8692
- match: {esql.queries.kibana.total: $kibana_total_counter}
@@ -109,7 +115,7 @@ setup:
109115
- do: {xpack.usage: {}}
110116
- match: { esql.available: true }
111117
- match: { esql.enabled: true }
112-
- length: { esql.features: 15 }
118+
- length: { esql.features: 18 }
113119
- set: {esql.features.dissect: dissect_counter}
114120
- set: {esql.features.drop: drop_counter}
115121
- set: {esql.features.eval: eval_counter}
@@ -125,6 +131,9 @@ setup:
125131
- set: {esql.features.sort: sort_counter}
126132
- set: {esql.features.stats: stats_counter}
127133
- set: {esql.features.where: where_counter}
134+
- set: {esql.features.lookup_join: lookup_join_counter}
135+
- set: {esql.features.lookup: lookup_counter}
136+
- set: {esql.features.inlinestats: inlinestats_counter}
128137
- length: { esql.queries: 3 }
129138
- set: {esql.queries.rest.total: rest_total_counter}
130139
- set: {esql.queries.rest.failed: rest_failed_counter}
@@ -153,6 +162,9 @@ setup:
153162
- gt: {esql.features.sort: $sort_counter}
154163
- gt: {esql.features.stats: $stats_counter}
155164
- gt: {esql.features.where: $where_counter}
165+
- match: {esql.features.lookup_join: $lookup_join_counter}
166+
- match: {esql.features.lookup: $lookup_counter}
167+
- match: {esql.features.inlinestats: $inlinestats_counter}
156168
- gt: {esql.queries.rest.total: $rest_total_counter}
157169
- match: {esql.queries.rest.failed: $rest_failed_counter}
158170
- match: {esql.queries.kibana.total: $kibana_total_counter}

0 commit comments

Comments
 (0)